Skip to content

emsifa/evo

Repository files navigation

Logo

Latest Version on Packagist GitHub Tests Action Status Coverage Status GitHub Code Style Action Status Total Downloads


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.

About

Evolve your Laravel code

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published