FastAPI-Style Attribute Routing for Laravel

Submitted by mustafakhaleddev - 2 months ago

FastAPI-inspired attribute-based routing to Laravel, simplifying the way routes, methods, and middlewares are defined. With this package, you can group routes using the FastAPIGroup attribute, set middleware directly on controllers, and specify HTTP methods and paths using attributes like FastAPI. This elegant approach allows developers to write cleaner, more organized, and maintainable route definitions, offering a powerful alternative to traditional Laravel routing.

//https://github.com/mustafakhaleddev/laravel-fast-api

#[FastAPIGroup(prefix: '/items', options: ['name' => 'items'], middlewares: ['auth'])]
class ItemsController extends Controller
{
    #[FastAPI(method: FastApiMethod::GET, path: '/data/{id}')]
    public function getItem($id)
    {
        return response()->json(['item' => $id]);
    }
}