Mezzio-swoole: got ServiceNotFoundException when using navigation component

In my mezzio-swoole testing project.

I followed steps:

use the command to install navigation:
composer require laminas/laminas-navigation

then added configuration in config/autoload/global.php as:

then added the following to templates/app/home-page.phtml

what I got as:

did I miss any key steps?

Unfortunately, yes. The description you followed is for a laminas-mvc based application.

Mezzio is not fully supported, yet. Some more handwork is needed.


But regardless of that, I don’t know if the navigation component works with Swoole.

What I really need is db-paginator, it is very normal function in a html web application.

There is another question, when I installed mezzio-swoole companent upon the simple mezzio-skeleton. Then I start up with command

composer run --timeout=86400 serve

command, it raised 500 error. which works totally ok before the mezzio-swoole component installed.

Then is laminas-navigation wrong here.

Which belongs not to this topic. Please open a new thread for this and add more details, for example a stack track.

no, what I followed is for Mezzio, I refered this document page. Installation - laminas-navigation - Laminas Docs

These parts are from the description for a laminas-mvc based application:

See the page for quick start:

Navigation container configuration

Add the container definition to your configuration file, e.g. config/autoload/global.php:

https://docs.laminas.dev/laminas-navigation/quick-start/#navigation-container-configuration

The following example demonstrates rendering the navigation menus for the named default , special , and sitemap containers.

https://docs.laminas.dev/laminas-navigation/quick-start/#using-multiple-navigations

I used the multiple one

11

33

You mean the multiple one can only be used in mvc-based?
If I want to use navigator in mezzio, I only can use the non-multiple one like Quick Start - laminas-navigation - Laminas Docs

The whoops shows no plugin “navigation” found in plugin manager
Maybe there is a missing step to register the navigation to Laminas\View\HelperPluginManager.

You wanna to tell that, all this is for mvc-based?

https://docs.laminas.dev/laminas-navigation/installation/#installation-for-mezzio-and-laminas-mvc-application

Please look carefully at the pages and headlines!

You can install laminas-navigation for a Mezzio application which is described here:

https://docs.laminas.dev/laminas-navigation/installation/

But you can not use the description for a laminas-mvc based application which is described here:

https://docs.laminas.dev/laminas-navigation/quick-start/

See the headline:

Quick Start

Usage in a laminas-mvc-based application


A Mezzio application is not fully supported, yet. Some more handwork is needed like the registration of the navigation view helper. That is the error message that you get.

thanks for your kind reply!

It is ok that I will not use navigation in my test project. It is not necessary for me. Thank you again :upside_down_face:

And to answer the question why Mezzio is not fully supported:

The factories for one navigation and the factory for multiple navigation will not work in a Mezzio application. The factories are all based on laminas-service-manager and to allow multiple navigations in a Mezzio application, a solution other than an abstract factory is needed.

This means that an extension of laminas-navigation is required before mezzio-navigation can be created.
I already have a solution but I have to find some time first to provide the solution. :disappointed:

okay, looking forward to your perfect solution :100:

I’m sorry I can’t give you a complete solution. But thank you for bringing up this topic and the problem with the documentation. I have already created a task for this:

until now for my project, I am applying swoole only for webservices. That will be a good ideia if you build you application with a MVC app (front) and build your backend with swoole

Avoid if possible.

Adding a network boundary in an application is a huge overhead for both software and developers, so there must be a strong business requirement that overruled the disadvantages of a monolithic approach.

And by “strong”, I mean really strong.

dont got it. are your trying to say to not use swoole?

Hey Leafar,

No, swoole is fine, but don’t build a two-layer app where you have a “presentation layer runtime” backed by an “API server”: it’s a lot of work that really only produces complexity.

Swoole can directly produce the presentation layer responses :+1: