PHPackages                             mkd/laravel-fast-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. mkd/laravel-fast-api

ActiveLibrary[API Development](/categories/api)

mkd/laravel-fast-api
====================

Laravel FastAPI is a PHP attribute-based routing package designed to streamline API development. It enables developers to define routes, methods, and middlewares directly within their controllers using simple PHP attributes. By reducing the complexity of traditional route definition, Laravel FastAPI improves code organization and enhances performance with route caching. Perfect for developers looking to build clean, efficient APIs in Laravel.

v0.0.1(1y ago)128MITPHPPHP ^8.0

Since Oct 16Pushed 1y ago2 watchersCompare

[ Source](https://github.com/mustafakhaleddev/laravel-fast-api)[ Packagist](https://packagist.org/packages/mkd/laravel-fast-api)[ Docs](https://github.com/mustafakhaleddev/laravel-fast-api)[ RSS](/packages/mkd-laravel-fast-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Laravel Fast-API
================

[](#laravel-fast-api)

[![Latest Version](https://camo.githubusercontent.com/06ee6499a7e00bb499fedbbc17d3c466f7fb2488d030967a91f836f61ec8f438/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6d7573746166616b68616c65646465762f6c61726176656c2d666173742d6170692e7376673f7374796c653d666c61742d737175617265)](https://github.com/mustafakhaleddev/laravel-fast-api/releases)[![Issues](https://camo.githubusercontent.com/d0f152307a8a477519458ffbdbd0a259e5bc932b24a540017706763d8bce6b65/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6d7573746166616b68616c65646465762f6c61726176656c2d666173742d6170692e7376673f7374796c653d666c61742d737175617265)](https://github.com/mustafakhaleddev/laravel-fast-api/issues)[![License](https://camo.githubusercontent.com/eb53d5299c8cb091b7c2edb10dc0acd9498df016beff548330ba1769dcb8ba6c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d7573746166616b68616c65646465762f6c61726176656c2d666173742d6170692e7376673f7374796c653d666c61742d737175617265)](https://github.com/mustafakhaleddev/laravel-fast-api/blob/main/LICENSE)

Laravel FastAPI is a PHP attribute-based routing solution for building APIs quickly and efficiently. With FastAPI attributes, you can define routes, methods, and middlewares directly in your controller classes, reducing the need for complex route files and enabling better organization and clarity.

This package also integrates seamlessly with Laravel's `route:cache` for enhanced performance, ensuring your APIs are as fast as possible.

Features
--------

[](#features)

- **Attribute-Based Routing**: Define your API routes using PHP attributes.
- **Support for Advanced Routing Options**: Middleware, where clauses, route options, and more!
- **Enum-Based HTTP Methods**: Use the predefined `FastApiMethod` for your HTTP methods.
- **API Caching**: Leverage Laravel's `route:cache` for optimal performance.
- **Clear API Cache**: Quickly clear cached API routes with simple Artisan commands.

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require mkd/laravel-fast-api
```

Usage
-----

[](#usage)

### Define FastAPI Routes

[](#define-fastapi-routes)

Use the `#[FastAPIGroup]` and `#[FastAPI]` attributes to define routes inside your controller classes.

```
use MKD\FastAPI\Attributes\FastAPI;
use MKD\FastAPI\Attributes\FastAPIGroup;

#[FastAPIGroup(prefix: '/items', options: ['name' => 'items'], middlewares: ['auth'])]
class ItemsController extends Controller
{
    #[FastAPI(method: FastApiMethod::GET, path: '/data/{id}', options: ['functions' => [
        'whereIn' => ['id', ['2']],
    ], 'name' => 'item_id'])]
    public function getItem($id)
    {
        return response()->json(['item' => $id]);
    }
}
```

This simple attribute-based approach automatically handles routing logic, allowing you to focus on building your API logic.

### Supported Methods and Functions

[](#supported-methods-and-functions)

You can define routes with the following HTTP methods:

```
enum FastApiMethod
{
    case GET;
    case POST;
    case PUT;
    case PATCH;
    case OPTION;
    case DELETE;
    case ANY;
    case REDIRECT;
    case MATCH;
}
```

In addition, you can leverage these functions to customize your routes:

```
private array $supportedFunctions = [
    'middleware',
    'where',
    'whereNumber',
    'whereAlpha',
    'whereAlphaNumeric',
    'whereUuid',
    'whereUlid',
    'whereIn',
    'name',
    'withTrashed',
    'scopeBindings',
    'withoutScopedBindings',
];
```

### Configurations

[](#configurations)

In your configuration file, you can specify paths and controllers to be scanned for FastAPI attributes.

```
return [
    //Paths to check for controllers that use fast-api
    'paths' => [
        app_path('Http/Controllers'),
    ],

    //Specify controllers that are not included in the paths
    'controllers' => [
        \App\Http\Controllers\CustomController::class
    ],
];
```

### Artisan Commands

[](#artisan-commands)

FastAPI provides useful commands for caching and clearing controllers:

- Cache the controllers for better scanning performance:

    ```
    php artisan fast-api:cache
    ```
- Clear the cached controllers:

    ```
    php artisan fast-api:clear-cache
    ```

### Performance

[](#performance)

By using Laravel's `route:cache`, the FastAPI routes are cached to ensure high performance. It is recommended to always cache your routes in production environments for faster API responses.

```
php artisan route:cache
```

Contributing
------------

[](#contributing)

Feel free to submit issues and pull requests. Contributions are welcome!

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

---

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

578d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25182746?v=4)[Mustafa Khaled](/maintainers/mustafakhaleddev)[@mustafakhaleddev](https://github.com/mustafakhaleddev)

---

Top Contributors

[![mustafakhaleddev](https://avatars.githubusercontent.com/u/25182746?v=4)](https://github.com/mustafakhaleddev "mustafakhaleddev (3 commits)")

---

Tags

apifastapilaravellaravel-frameworklaravel-packagemiddlewarelaravellaravel-packagesfastapiphp-attributesapi developmentAPI RoutingRoute Caching

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mkd-laravel-fast-api/health.svg)

```
[![Health](https://phpackages.com/badges/mkd-laravel-fast-api/health.svg)](https://phpackages.com/packages/mkd-laravel-fast-api)
```

###  Alternatives

[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k34.0M112](/packages/darkaonline-l5-swagger)[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[knuckleswtf/scribe

Generate API documentation for humans from your Laravel codebase.✍

2.3k12.2M45](/packages/knuckleswtf-scribe)[vemcogroup/laravel-weather

Weather package for Laravel to use different providers to get weather info

5525.0k](/packages/vemcogroup-laravel-weather)[scriptdevelop/whatsapp-manager

Paquete para manejo de WhatsApp Business API en Laravel

762.6k](/packages/scriptdevelop-whatsapp-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
