PHPackages                             larafast/fastapi - 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. larafast/fastapi

ActiveLibrary[API Development](/categories/api)

larafast/fastapi
================

A Fast Laravel package to help you generate CRUD API Controllers and Resources, Model

2.7(3y ago)1233.9k↓46.2%15[2 PRs](https://github.com/Mahmoud-Italy/Larafast-fastApi/pulls)MITPHPPHP ^8.1

Since Jul 14Pushed 1y ago6 watchersCompare

[ Source](https://github.com/Mahmoud-Italy/Larafast-fastApi)[ Packagist](https://packagist.org/packages/larafast/fastapi)[ RSS](/packages/larafast-fastapi/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelog (8)Dependencies (4)Versions (10)Used By (0)

Larafast FastAPI
================

[](#larafast-fastapi)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/138f86cbe096338ac8e8d1dee2f31bc523fb08c98eccb6e29e55966946397ee8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4d61686d6f75642d4974616c792f4c617261666173742d666173744170692f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Mahmoud-Italy/Larafast-fastApi/?branch=master)[![Build Status](https://camo.githubusercontent.com/32c5a4318a8df212e0c0e34116553489856e4af7fd0fb17ce5215c16578916a8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4d61686d6f75642d4974616c792f4c617261666173742d666173744170692f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Mahmoud-Italy/Larafast-fastApi/build-status/master)[![Code Intelligence Status](https://camo.githubusercontent.com/22b0fe007adafb7b87a7c812ca97094978a4182636ba4b046adb830b16951e6e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4d61686d6f75642d4974616c792f4c617261666173742d666173744170692f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d6d6173746572)](https://scrutinizer-ci.com/code-intelligence)[![Total Downloads](https://camo.githubusercontent.com/57e8627f83bf37e74a6509df6ed914c01670bd742e362831b5f6df255e51476d/68747470733a2f2f706f7365722e707567782e6f72672f6c617261666173742f666173746170692f642f746f74616c2e737667)](https://packagist.org/packages/larafast/fastapi)[![fast-api](assets/background.jpg)](assets/background.jpg)

What does mean FastAPI:
=======================

[](#what-does-mean-fastapi)

A Fastapi Laravel package to help you generate CRUD API Controllers and Resources, Model.. etc

What actually do?
=================

[](#what-actually-do)

Suppose you are building an api, and you want to create controller and resources and model and factory.. etc, then you have to do a ton of other tedious and to be honest, boring things like creating migrations, model factories, the controller, form validation and adding all.

So what FastAPI does is when you tell it the model name, it will do all those boring things. When it's done you have the following:

- Blog.php
- BlogController.php ship with code already exists
- BlogStoreRequest.php and BlogUpdateRequest.php
- BlogResource.php
- Timestamped create\_blogs\_table.php migration file
- BlogFactory.php

Installation
============

[](#installation)

```
composer require larafast/fastapi
```

Then publish the config
=======================

[](#then-publish-the-config)

```
php artisan vendor:publish --tag=fastApi
```

For Lumen
=========

[](#for-lumen)

Just Add this line into bootstrap/app.php

```
$app->register(Larafast\Fastapi\FastapiServiceProvider::class);
```

Example
=======

[](#example)

```
php artisan fastApi Blog
```

Once done, it will show you the details of the files generated.

```
Factory created successfully

Created Migration: 2020_07_14_125128_create_blogs_table

Model created successfully

Controller created successfully

Request created successfully

Request created successfully

Resource created successfully
```

Snapshot of BlogController
==========================

[](#snapshot-of-blogcontroller)

```
namespace App\Http\Controllers;

use App\Blog;
use Illuminate\Http\Request;
use App\Http\Requests\BlogUpdateRequest;
use App\Http\Requests\BlogStoreRequest;
use App\Http\Resources\BlogResource;

class BlogController extends Controller
{
    function __construct()
    {
        // $this->middleware('permission:view_blogs', ['only' => ['index', 'show']]);
        // $this->middleware('permission:add_blogs',  ['only' => ['store']]);
        // $this->middleware('permission:edit_blogs', ['only' => ['update']]);
        // $this->middleware('permission:delete_blogs', ['only' => ['destroy']]);
    }

    public function index()
    {
        $rows = BlogResource::collection(Blog::filter());
        return response()->json([
            'rows'        => $rows,
            'paginate'    => $this->paginate($rows)
        ], 200);
    }

    public function store(BlogStoreRequest $request)
    {
        $row = Blog::createOrUpdate(NULL, request()->all());
        if($row === true) {
            return response()->json(['message' => ''], 201);
        } else {
            return response()->json(['message' => 'Unable to create entry ' . $row], 500);
        }
    }

    public function show($id)
    {
        $row = new BlogResource(Blog::findOrFail(decrypt($id)));
        return response()->json(['row' => $row], 200);
    }

    public function update(BlogUpdateRequest $request, $id)
    {
        $row = Blog::createOrUpdate(decrypt($id), request()->all());
        if($row === true) {
            return response()->json(['message' => ''], 200);
        } else {
            return response()->json(['message' => 'Unable to update entry ' . $row], 500);
        }
    }

    public function destroy($id)
    {
        try {
            $row = Blog::query();

            // can work with multi select
            if(strpos($id, ',') !== false) {
                foreach(explode(',',$id) as $sid) {
                    $ids[] = $sid;
                }
                $row->whereIN('id', $ids);
            } else {
                $row->where('id', $id);
            }
            $row->delete();

            return response()->json(['message' => ''], 200);
        } catch (\Exception $e) {
            return response()->json(['message' => 'Unable to delete entry, '. $e->getMessage()], 500);
        }
    }
}

```

Snapshot of Blog Model
======================

[](#snapshot-of-blog-model)

```
namespace App;

use DB;
use App\Image;
use Illuminate\Pipeline\Pipeline;
use Larafast\Fastapi\QueryFilters\Sort;
use Larafast\Fastapi\QueryFilters\Locale;
use Larafast\Fastapi\QueryFilters\Search;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Model;

class Blog extends Model
{
    protected $guarded = [];

    // imageable polymorphic
    public function image() {
        return $this->morphOne(Image::class, 'imageable');
    }

    // Filter
    public static function filter()
    {
        return app(Pipeline::class)
                ->send(self::query())
                ->through(
                [
                    Locale::class,
                    Search::class,
                    Sort::class
                ])
                ->thenReturn()
                ->paginate(request('paginate') ?? 10);
    }

    // Create or Update
    public static function createOrUpdate($id, $value)
    {
        try {

            // Begin Transaction
            DB::beginTransaction();

                // find Or New
                $row              = (isset($id)) ? self::find($id) : new self;
                $row->title       = $value['title'] ?? NULL;
                $row->body        = $value['body'] ?? NULL;
                $row->save();

                // Image
                if(isset($value['image'])) {
                    $row->image()->delete();
                    if($value['image']) {
                        if(!Str::contains($value['image'], [ Imageable::contains() ])) {
                            $image = Image::uploadImage($value['image']);
                        } else {
                            $image = explode('/', $value['image']);
                            $image = end($image);
                        }
                        $row->image()->create([ 'url' => $image ]);
                    }
                }

            DB::commit();
            // End Commit of Transaction

            return true;
        } catch (\Exception $e) {
            DB::rollback();
            return $e->getMessage();
        }
    }
}

```

Snapshot of Blog Resource
=========================

[](#snapshot-of-blog-resource)

```
namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class BlogResource extends JsonResource
{

    public function toArray($request)
    {
        return [
            'id'            => $this->id,
            'encrypt_id'    => encrypt($this->id),
            'image'         => ($this->image) ? $this->image->url : NULL,

            'title'         => $this->title,
            'body'          => $this->body,

            'dateForHumans' => $this->created_at->diffForHumans(),
            'timestamp'     => $this->created_at
        ];
    }
}
```

Now add the necessary fields and run

```
php artisan migrate
```

And that saved you an hour worth of repetitive and boring work which you can spend on more important development challenges.

Credits
=======

[](#credits)

- [Mahmoud Italy](https://github.com/Mahmoud-Italy)
- [All Contributors](https://github.com/Mahmoud-Italy/Larafast-fastApi/graphs/contributors)

License
=======

[](#license)

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

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 94.8% 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

Every ~248 days

Recently: every ~431 days

Total

8

Last Release

395d ago

Major Versions

v1.0.0 → v2.02020-07-28

PHP version history (2 changes)v1.0.0PHP ^7.2

2.7PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/17962343?v=4)[Mahmoud Ahmed](/maintainers/Mahmoud-Italy)[@Mahmoud-Italy](https://github.com/Mahmoud-Italy)

---

Top Contributors

[![Mahmoud-Italy](https://avatars.githubusercontent.com/u/17962343?v=4)](https://github.com/Mahmoud-Italy "Mahmoud-Italy (92 commits)")[![thefeqy](https://avatars.githubusercontent.com/u/44809366?v=4)](https://github.com/thefeqy "thefeqy (3 commits)")[![luismabenitez](https://avatars.githubusercontent.com/u/5616886?v=4)](https://github.com/luismabenitez "luismabenitez (1 commits)")[![mahmoudMagdy1255](https://avatars.githubusercontent.com/u/37344675?v=4)](https://github.com/mahmoudMagdy1255 "mahmoudMagdy1255 (1 commits)")

---

Tags

api-generatorfastapigenerategenerate-apilarafastlaravellumenscaffoldscaffoldgeneratefastapiapi-generatorgenerate apilarafast

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/larafast-fastapi/health.svg)

```
[![Health](https://phpackages.com/badges/larafast-fastapi/health.svg)](https://phpackages.com/packages/larafast-fastapi)
```

###  Alternatives

[andreaselia/laravel-api-to-postman

Generate a Postman collection automatically from your Laravel API

1.0k586.2k3](/packages/andreaselia-laravel-api-to-postman)[essa/api-tool-kit

set of tools to build an api with laravel

52680.5k](/packages/essa-api-tool-kit)[bhavingajjar/laravel-api-generator

a laravel rest api generator with API Resources

487.7k](/packages/bhavingajjar-laravel-api-generator)[johnylemon/laravel-apidocs

Laravel API documentation generating tool

472.8k](/packages/johnylemon-laravel-apidocs)[yxx/laravel-quick

agile development

145.3k](/packages/yxx-laravel-quick)[liinkiing/graphql-maker-bundle

Bundle to easily create GraphQL types for Overblog GraphQLBundle

103.9k](/packages/liinkiing-graphql-maker-bundle)

PHPackages © 2026

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