Evo is a Laravel package that leverages PHP 8 features. It change the way you write Laravel app into something like this:
#[RoutePrefix('users')]
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
}
}
Defining 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.
- Register routes using attributes.
- Apply middleware using attribute.
- Route prefixing using attribute.
- Inject request data (Header, Param, Cookie, Body, Query) into parameters using attribute.
- Automatic type casting.
- Automatic type validation.
- Define validation rules directly in DTO properties using attribute.
- Custom value caster.
- Generate DTO file.
- Generate Response file.
- Generate Swagger UI and OpenAPI file.
- Mocking API.
Evo currently is still in the development, it could have some breaking changes before the final release.
You can install the package via composer:
composer require emsifa/evo:dev-main
See https://www.emsifa.com/evo.
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.