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

Getting Started

Start by installing the package via Composer: composer require laminas/laminas-mvc. This package provides the core MVC infrastructure for Laminas applications—including the Application, MvcEvent, and controller infrastructure. Your first use case will likely be bootstrapping a basic MVC application: create a minimal config/application.config.php with module metadata and controller mappings, then define routes and controllers to handle requests. Check the config/modules.config.php to ensure Laminas\Mvc is listed, and verify your public/index.php initializes the application using Laminas\Mvc\Application::init(). The Laminas\Mvc\Controller\AbstractActionController is the typical base class for controllers—extend it and implement indexAction() to render your first route.

Implementation Patterns

  • Event-driven flow: Leverage MvcEvent lifecycle events (EVENT_ROUTE, EVENT_DISPATCH, EVENT_RENDER) in Module::onBootstrap() to inject logic like authentication checks or logging.
  • Controller plugins: Use built-in plugins (forward(), redirect(), flashMessenger()) inside controllers for common tasks—register custom plugins via PluginManager configuration.
  • Service-based controllers: Inject services (e.g., UserService) into controllers via constructor or setter injection, configured in Module.php's getServiceConfig().
  • Module separation: Organize code using the Module pattern—each module defines routes, controllers, and dependencies in its Module.php, enabling reusable and decoupled domain logic.
  • RESTful controllers: Extend AbstractRestfulController for APIs, implementing getList(), get(), create(), etc., and return JsonModel responses natively.

Gotchas and Tips

  • Routes must match HTTP methods: A GET route won’t dispatch to a post() action—ensure route definitions (e.g., in module.config.php) align with intended HTTP verbs.
  • Controller naming conventions: Controller classes must end with Controller, and actions with Action; case-sensitive autoloading in Linux environments can cause 404s if naming mismatches occur.
  • PluginManager registration: Custom controllers and plugins must be registered in controllers and controller_plugins sections of the ServiceManager config—omitting this yields "service not found" errors at runtime.
  • Event manager chaining: Avoid infinite loops when attaching listeners to MvcEvent::EVENT_DISPATCH—always guard with event name !== 'dispatch' or check if already dispatched.
  • Dependency injection in factories: Prefer factory-based controller instantiation over invokables in config/autoload/local.php for controllers requiring dependencies—AbstractActionController is not invokable if you add constructor arguments.
  • Legacy compatibility: This package supports Laminas’s older MVC stack; for new projects, consider laminas/laminas-api-tool or mezzio (Laminas’s PSR-7/15-based microframework) for modern HTTP handling.
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
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
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