Introduction
Evo is a Laravel package that leverages PHP 8 features. It change the way you write Laravel app into something like this:
#[RoutePrefix('users')]#[RouteMiddleware('auth')]class UserController extends Controller{ #[Get] public function index( #[Query] int $limit, #[Query] int $offset, #[Query('q')] string $keyword, ): UserPaginationResponse { // your logic goes here }
#[Post] public function store( #[Body] CreateUserDto $data ): StoreUserResponse { // your logic goes here } #[Put('{id}')] public function update( #[Param] int $id, #[Body] UpdateUserDto $data, ): UpdateUserResponse { // your logic goes here }}
#
MotivationDefining input and output types in a head of a function will trigger your brain to specifies input and output types before writing the logic. So when it comes to write the logic, you know exactly what you have, where it comes, and what to return.
Also, by defining input and output type in this way, not only you and your teammate would easily read the specifications. Machines too. That is why Evo can provide some amazing features such as auto validation, auto casting, live swagger documentation, mocking API, etc.