Looking to hire Laravel developers? Try LaraJobs

laravel-fast-endpoints maintained by baghunts

Description
Laravel routes new (fast) experience
Author
Last update
2024/08/19 14:29 (dev-master)
License
Links
Downloads
14

Comments
comments powered by Disqus

Laravel Fast Endpoints

Packagist Tests Codecov Downloads GitHub license

LFE (Laravel Fast Endpoints) is a developer-friendly and efficient alternative to traditional MVC for providing API services to clients. It introduces a new, fast approach using PHP Attributes and a File-Driven architecture. With LFE, there's no need to manually define routes—they are automatically registered, streamlining the development process.

Installation

You can install the package via composer:

composer require baghunts/laravel-fast-endpoints

Quick Example

Let's walk through a simple example to demonstrate how easy it is to create an API endpoint with LFE.

<?php  
  
namespace App\Http\Endpoints\HelloWorld;  
  
use Baghunts\LaravelFastEndpoints\Attributes\Get;  
use Baghunts\LaravelFastEndpoints\Endpoint\Endpoint;  
  
#[Get('/hello-world')]  
class HelloWorldEndpoint extends Endpoint  
{  
    /**  
     * Handle the incoming request for the endpoint with path '/hello-world'
     * 
     * @return string  
     */
    public function __invoke(): string  
    {  
        return 'Hello World!';  
    }  
}

LFE automatically registers the route for this endpoint.

use App\Http\Endpoints\HelloWorld\HelloWorldEndpoint;

Route::get('/hello-world', HelloWorldEndpoint::class)

That's it! You've just created and accessed an API endpoint using LFE with minimal setup. For more details and advanced usage, explore the rest of the documentation.

This quick example will give users a hands-on feel for how LFE simplifies the process of creating API endpoints, making the benefits immediately clear.