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

Hmvc Laravel Package

spiral/hmvc

HMVC support for Spiral apps, helping you structure features into self-contained modules with controllers, views, and routes. Encourages clean separation of concerns and scalable project organization for complex applications.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Install via Composer: composer require spiral/hmvc
  • This package provides HMVC (Hierarchical Model-View-Controller) functionality used by the Spiral Framework; it’s not meant for standalone use.
  • Primary entry point is the Spiral\HMVC\Controller base class—extend it to build modular controllers with nested actions, middleware stacking, and dependency injection.
  • Check src/Controller.php and src/ControllerInterface.php for core abstractions. Look at Spiral’s official framework docs or source (since this is a subtree split) for real-world examples—self-contained usage is rare.

Implementation Patterns

  • Nested Controllers: Use controller chaining to compose hierarchical logic (e.g., UserController invoking ProfileController internally), reducing duplication and increasing modularity.
  • Action-as-methods: Define public methods (e.g., actionIndex(), actionView($id)) as routeable actions; avoid direct controller instantiation—let the framework resolve via DI.
  • Middleware Integration: Register middleware on controllers via middleware() in constructor or via config—works with Spiral’s router and HTTP pipeline.
  • Dependency Injection: Leverage constructor/method injection for services; the component integrates tightly with Spiral’s IoC container.

Gotchas and Tips

  • ⚠️ No Active Maintenance: Last release was in 2020; avoid for new projects unless locked to Spiral v2.x. Check spiral/framework repo for HMVC evolution.
  • This package is ** read-only and split** from spiral/framework—debugging issues will likely require referencing the parent framework’s codebase (especially src/Controller implementations).
  • Route naming conflicts: When nesting controllers, ensure action names don’t collide—prefixed names (e.g., profile_actionView) help avoid ambiguity.
  • DI limitations: If used outside Spiral’s full stack, ensure your DI container supports cyclic dependencies and complex resolution—this component assumes Spiral’s DI ecosystem.
  • For long-term stability, consider migrating to spiral/router + spiral/http with modern controllers instead of relying solely on HMVC if upgrading.
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
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