Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laminas Mvc Laravel Package

laminas/laminas-mvc

Laminas MVC is a modular, event-driven MVC framework for PHP applications. It provides routing, controllers, view integration, dependency injection, and configuration management, helping you build scalable, maintainable web apps and APIs on top of Laminas components.

View on GitHub
Deep Wiki
Context7

Modules

A module is a PHP namespace. It can contain controllers, classes, view scripts, configuration, tests, as well as public assets such as images, CSS, and JavaScript. For example, if you have an e-commerce application, you could have a module for presenting and selling products, and another for administrators to create products and manage orders.

File and Directory Structure

Given a module named Application, here is the recommended structure:

Application/
    config/
        module.config.php
    public/
        images/
        css/
        js/
    src/
        Controller/
            ProductController.php
        Module.php
        <other classes>
    test/
        Controller/
            ProductControllerTest.php
    view/
        application/
            product/
                list.phtml
        layout/
            layout.phtml

Loading

All module classes can be autoloaded by Composer by adding them as a namespace in composer.json:

"autoload": {
    "psr-4": {
        "Application\\": "module/Application/src/"
    }
}

This means that whenever you refer to a class in the Application namespace, PHP will look for it in the module/Application/src/ folder. A class named Application\Controller\ProductController would be found in the file module/Application/src/Controller/ProductController.php.

In addition to autoloading, the application needs to be aware that the Application namespace represents a module. This is accomplished by adding it to the module configuration of the application in config/modules.config.php:

return [
    'Application',
    // other modules
];

Listeners

Each module has a Module class, which can contain a variety of methods called listeners. These listeners are called by laminas-modulemanager to configure the module.

For the namespace Application, the module manager will look for Application\Module. Here is a simple example that loads a module-specific configuration file:

namespace Application;

class Module
{
    public function getConfig(): array
    {
        /** [@var](https://github.com/var) array $config */
        $config = include __DIR__ . '/../config/module.config.php';
        return $config;
    }
}

getModuleDependencies()

Checks each module to verify whether all the modules it depends on were loaded. Each of the values returned by the method is checked against the loaded modules list: if one of the values is not in that list, a Laminas\ModuleManager\Exception\MissingDependencyModuleException is thrown.

namespace Application;

use Laminas\ModuleManager\Feature\DependencyIndicatorInterface;

class Module implements DependencyIndicatorInterface
{
    public function getDependencies(): array
    {
        return [
            'Product'
        ];
    }
}

// Add other methods following the same structure as getModuleDependencies()

Be sure to read about Best Practices when Creating Modules.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation
uri-template/tests