You can generate a controller by following command.
php artisan mojura:controller [Controller] [Module] [Directory] [--force]
php artisan mojura:controller Auth Core
Generated controller file will be at app/Modules/CoreModule/Http/Controllers/AuthController.php
Parameters
-
[Controller]: The name of the controller you want to create (required).
-
[Module]: The module where the controller will be created (required).
-
[Directory]: The specific directory within the module where the controller will be placed (optional).
-
[--force]: If set, it will overwrite any existing controller with the same name (optional).
Controller Class Implementation - Serving Features
The Controller must inherit the Mojura Controller InnoAya\Mojura\Core\Controller
to work with the serve
method.
Controller classes are automatically inherited when you generate a Controller using Mojura Command.
Call serve
within the Controller method.
namespace App\Modules\CoreModule\Http\Controllers;
use InnoAya\Mojura\Core\Controller;
use App\Modules\CoreModule\Features\LoginUserFeature;
class AuthController extends Controller
{
public function login()
{
return $this->serve(new LoginUserFeature());
}
}