froschdesign / zend-expressive-navigation

Page, middleware and factories for navigations in a zend-expressive application
BSD 3-Clause "New" or "Revised" License
5 stars 5 forks source link

Can I use this library? #1

Closed fadoe closed 6 years ago

fadoe commented 6 years ago

I'am wonder how I can use zend-navigation in zend-expressive. I found this repository (zend-expressive-navigation) and this issue: https://github.com/zendframework/zend-navigation/issues/56.

Do I need zend-expressive-navigation to include easy zend-navigation? Is there any documentation how to do it? Why can't I find this repo on packagist.org? What is the current status?

RalfEggert commented 6 years ago

After messing around for a while, I managed to install the package. Please update your composer.json and add the repo:

"repositories": [
    // maybe you have other repos already
    {
      "url": "https://github.com/froschdesign/zend-expressive-navigation.git",
      "type": "git"
    }
  ],

Then install it:

$ composer require zendframework/zend-expressive-navigation:dev-master

Now you can use it. I will give it a try right now.

ghost commented 6 years ago

I have this up and running in a project that I just converted from ZF2 to Expressive, but I had to comment out a few lines in NavigationMiddlewareFactory to get it to behave as I expected. As an example, if my navigation was called Zend\Navigation\Example, it kept forcing me to (also) have a navigation with the default name Zend\Navigation\Navigation.

I have the same Composer repositories config as above, plus the following configuration:

Pipeline:

// Zend\Expressive\Navigation\Middleware\NavigationMiddleware
$app->pipe(NavigationMiddleware::class);

Dependencies:

// Zend\Expressive\Navigation\Service\ExpressiveNavigationAbstractServiceFactory
'Zend\Navigation\Example' => ExpressiveNavigationAbstractServiceFactory::class,

View:

<?= $this->navigation('Zend\Navigation\Example')
    ->menu()
    ->setPartial('example-module::navigation/example');

The following is the code that I removed. I'm not really sure of its purpose! To me it reads "if you have exactly one navigation container, add another with the default name. Eh? If it were "=== 0" that might make some sense. Dunno!

        if (\count($names) === 1) {
            $this->containerNames[] = Navigation::class;
            return $this->containerNames;
        }
RalfEggert commented 6 years ago

Please note that I added a quick start here:

https://github.com/froschdesign/zend-expressive-navigation/issues/2

But I have to admit, that I did not use the Navigation View Helper so far.

froschdesign commented 6 years ago

@fadoe Ralf has answered a part of your question. (Thanks to @RalfEggert!)

Do I need zend-expressive-navigation to include easy zend-navigation?

Yes, if you use a zend-expressive based application.

Why can't I find this repo on packagist.org? What is the current status?

The work on this component is still ongoing. After that the repository will move to the zendframework organisation and then it will be at packagist.org. In the meantime you can use this repository as shown above or described in the Composer documentation.

froschdesign commented 6 years ago

@kgrey Please create a new issue report for your problem. Thanks!

froschdesign commented 6 years ago

Closing in favour of #2 and #5