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.
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:
execute() takes no arguments (no task dispatching built-in).getInput() and getApplication() are set before calling execute() — otherwise, runtime exceptions will occur.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();
SaveUser, DeleteProduct, PublishItem) — avoid internal switch on task names.PrevalidateController → SaveController → NotifyController) to keep concerns decoupled.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.$_SERVER, $_GET, $_POST, etc., to Joomla\Input\Input and boot a minimal AbstractApplication subclass with dummy/PSR-11 container integration.Input and Application in unit tests; write integration tests that simulate full request/response flow using lightweight Joomla-based bootstraps.php-cs-fixer or PHPStan early.Request to Input, or bridge Laravel’s container with Joomla’s Application.execute() to log $this->getInput()->all() when troubleshooting — this helps diagnose missing or malformed request data early.How can I help you explore Laravel packages today?