Help me to understand

Hi community

It’s been a while since I’ve been working on a Laminas project, just doing tasks and developing some features. However, this project makes me feel like I’m not really a developer. I don’t know why I like this framework, but I can’t seem to understand many things, like the ServiceManager, EventManager, AuthService, Listeners, Adapter, and Module architecture.

I need help because I often hear people say things or use terms that make me wonder, 'What is that? What are they talking about?

thanks for all of you

Hi :slight_smile:

Well, there is a lot in that question. The first thing to understand about laminas or mezzio is that its component based and each of those components can be used standalone in nearly any project. Laminas MVC is just built on top of those components. It provides core service classes to create the “framework” in its own package laminas-mvc.

I guess you could say that ServiceManager is the heart of any Laminas MVC application. It is what consumes the merged application configuration that provides service mappings, both for your custom services and the core application services. It implements the PSR-11 ContainerInterface and manages the creation, storage and retrieval of service instances.

Laminas MVC is an event driven framework. It utilizes the laminas EventManager component to accomplish this. It creates the needed listeners and events that drives the overall workflow of the application. Listeners are what allows you to get into that workflow at critical points in execution and to execute your own code to modify the execution flow. You can attach your listeners to the events exposed by the framework to get into its execution flow or you can provide your own custom events as well.

The module architecture is provided to simplify the structure of your application and to promote well organized code. Unless it has changed this is accomplished by using the ModuleManager component. It is basically what reads your Module.php files (which returns your modules config file) and makes your modules code available to the application you are building. If it is done correctly that allows you to create portable modules that are reusable in all of your applications and that are nearly plug-n-play.

AuthService… I take it you mean AuthenticationService and that is simply another laminas component that you can use to authenticate users for your application. It exposes different adapters that target the different means of accomplishing authentication for web applications.

All of the components are documented. Some better than others and they are done so in a way that usually shows their standalone usage as well as a section about using them in a Laminas MVC application or Mezzio application.

To really get my head around it. First I figured out the details on how its configured and you can find that information here:

I then turned my attention to the Application class provided by the laminas/laminas-mvc package and read through the code to see how they themselves were using the different components to provide the framework functionality.

To understand the conversations surrounding the framework. Well, for the most part as far as I have seen its just OO jargon that is framework related :slight_smile:

I’m in the same boat actually, it’s hard to get my head around it without some sort of explain like I’m 5 type of thing.

Thank you very much for your time. now understand some of it, and I will continue to ask questions and read to reach a complete understanding.
I have many things in mind to do, but the problem I face is figuring out how to do them and whether it’s the best practice.
thank you @Tyrsson

If this is for a new application I would highly recommend starting it with Mezzio instead of the MVC. It’s a much simpler paradigm (psr 7/15 middleware/handlers) for building http applications.

You’re welcome. Any time you have questions please feel free to run a search and if nothing is returned then of course post a topic. Even if you get results but do not fully understand it, post your question and link to the topic you found.

1 Like

@Nerji
Well, start you some topics and the community will do our best to answer them for ya. :slight_smile:

1 Like

I can understand him. It was the same for me at the beginning and it still is. The problem is that the framework requires a lot of know-how from the design patterns world. E.g What would be a difference between an AuthManager and a AuthService? What do you imply by using one or the other word. When you start reading the beginner tutorial you often feel overwhelmed with some many words coming from the design patterns world and are taken for granted.