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

Controller Laravel Package

joomla/controller

Lightweight Joomla Framework controller package. Defines a ControllerInterface and an AbstractController base that wires in Input and Application objects. Implement execute() in your controller (single-task by default), with support for multi-task or HMVC patterns.

View on GitHub
Deep Wiki
Context7

Getting Started

Install the package with composer require joomla/controller. Begin by creating a controller class that extends Controller\AbstractController and implements the required execute() method — this is your core request-handling logic. Inject Joomla\Input\Input and Joomla\Application\AbstractApplication (e.g., WebApplication) via the constructor for most use cases. Key first steps:

  • Understand that execute() takes no arguments (no task dispatching built-in).
  • Ensure getInput() and getApplication() are set before calling execute() — otherwise, runtime exceptions will occur.
  • Use a minimal front controller or router to instantiate and invoke your controller class when a request arrives.

Example:

use Joomla\Controller\AbstractController;
use Joomla\Input\Input;
use Joomla\Application\WebApplication;

class ExportController extends AbstractController
{
    public function execute(): void
    {
        $input = $this->getInput();
        $format = $input->getCmd('format', 'csv');

        // Perform export logic...
    }
}

// In your front controller
$app  = new WebApplication();
$input = new Input\Input($_REQUEST);
$controller = new ExportController($input, $app);
$controller->execute();

Implementation Patterns

  • Task-per-Controller Design: Each controller handles one high-level user action (e.g., SaveUser, DeleteProduct, PublishItem) — avoid internal switch on task names.
  • Controller Chaining for HMVC: Since the base class doesn’t restrict invoking other controllers, chain them programmatically for layered logic (e.g., PrevalidateControllerSaveControllerNotifyController) to keep concerns decoupled.
  • Input/Output Decoupling: Wrap Input in value objects before passing to models/services to avoid tight coupling to Joomla’s input API. Similarly, handle output (e.g., JSON, redirects) via PSR-7 response objects if integrating with middleware stacks.
  • Adaptive Application Layer: If working outside Joomla’s full framework (e.g., in Laravel), write adapters to map $_SERVER, $_GET, $_POST, etc., to Joomla\Input\Input and boot a minimal AbstractApplication subclass with dummy/PSR-11 container integration.
  • Testing Strategy: Inject mocks for Input and Application in unit tests; write integration tests that simulate full request/response flow using lightweight Joomla-based bootstraps.

Gotchas and Tips

  • No built-in routing: This package only provides execution, not dispatching. You must implement routing (URL → controller class + method) yourself (e.g., via Symfony Router or custom dispatcher).
  • Serialization quirks: The application object is not preserved on serialize/unserialize — only input is. If storing controllers in sessions (e.g., multi-step forms), re-inject application after unserialization or avoid serialization entirely.
  • Strict PHP 8.3+ requirement (v4.x): Ensure all code follows PSR-12 and uses strict types. Missing return types or type hints will cause CI failures — enable php-cs-fixer or PHPStan early.
  • GPL-2.0 license risk: If building proprietary software, confirm compatibility. GPL may require derivative works to be open-sourced — consider forking and relicensing if critical.
  • Zero ecosystem tooling: No official Laravel/Symfony integrations exist. Expect to write glue code: e.g., convert Symfony’s Request to Input, or bridge Laravel’s container with Joomla’s Application.
  • Debug tip: Temporarily override execute() to log $this->getInput()->all() when troubleshooting — this helps diagnose missing or malformed request data early.
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