emsifa / evo
Evolutionize the way you write Laravel code
Fund package maintenance!
emsifa
Requires
- php: ^8.0
- illuminate/contracts: ^8.37
- illuminate/http: ^8.49
- illuminate/support: ^8.49
- illuminate/validation: ^8.49
- spatie/laravel-package-tools: ^1.4.3
Requires (Dev)
- brianium/paratest: ^6.2
- dms/phpunit-arraysubset-asserts: ^0.3.0
- nunomaduro/collision: ^5.3
- orchestra/testbench: ^6.15
- php-coveralls/php-coveralls: ^2.4
- phpunit/phpunit: ^9.3
- spatie/laravel-ray: ^1.9
- vimeo/psalm: ^4.4
README
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 } }
Motivation
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.
Features
- 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.
Installation
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
Documentation
See https://www.emsifa.com/evo.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.