Laravel: Single Action Controller
22 August 2024 (Updated 22 August 2024)
Generate:
php artisan make:controller ProvisionServer --invokable
Edit as needed:
<?php
namespace App\Http\Controllers;
class ProvisionServer extends Controller
{
/**
* Provision a new web server.
*/
public function __invoke()
{
// ...
}
}
Add route:
use App\Http\Controllers\ProvisionServer;
Route::post('/server', ProvisionServer::class);
Tagged:
Laravel