PHPackages                             shaburov/laravel-crud-rest-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. shaburov/laravel-crud-rest-api

ActiveLibrary[API Development](/categories/api)

shaburov/laravel-crud-rest-api
==============================

Crud Rest Api package for creating other crud controllers.

v1.1.0(3y ago)37.5kMITPHPPHP ^8.0CI failing

Since Sep 11Pushed 3y ago2 watchersCompare

[ Source](https://github.com/ishaburov/crud-rest-api)[ Packagist](https://packagist.org/packages/shaburov/laravel-crud-rest-api)[ RSS](/packages/shaburov-laravel-crud-rest-api/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (4)Versions (6)Used By (0)

CRUD rest-api based on Laravel
==============================

[](#crud-rest-api-based-on-laravel)

[![Build Status](https://camo.githubusercontent.com/b9ccf68b3694017016f6fbb87fd165aa9d395c5694f49f9a6a71e24c79309d36/68747470733a2f2f7472617669732d63692e636f6d2f697368616275726f762f637275642d726573742d6170692e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/ishaburov/crud-rest-api)[![Latest Stable Version](https://camo.githubusercontent.com/65e0645c3d2bb610a87fb45cf307141664f6888692a2cc86b262ecaa4236c7f7/68747470733a2f2f706f7365722e707567782e6f72672f7368616275726f762f6c61726176656c2d637275642d726573742d6170692f76)](//packagist.org/packages/shaburov/laravel-crud-rest-api)[![Total Downloads](https://camo.githubusercontent.com/d6ebc9729cbcfd16002bb8bd564190f480721d5bf8ae4b6c0cdfc75fb2817496/68747470733a2f2f706f7365722e707567782e6f72672f7368616275726f762f6c61726176656c2d637275642d726573742d6170692f646f776e6c6f616473)](//packagist.org/packages/shaburov/laravel-crud-rest-api)[![Latest Unstable Version](https://camo.githubusercontent.com/04c88191bd52d3c8667eb896b946a02a5b0379e8b349877a1957e8d7553eca7f/68747470733a2f2f706f7365722e707567782e6f72672f7368616275726f762f6c61726176656c2d637275642d726573742d6170692f762f756e737461626c65)](//packagist.org/packages/shaburov/laravel-crud-rest-api)[![License](https://camo.githubusercontent.com/aa860d6cc1a3b2bd685cbab5758529be930c1420bcbc6e0917f53fc340a3a2f6/68747470733a2f2f706f7365722e707567782e6f72672f7368616275726f762f6c61726176656c2d637275642d726573742d6170692f6c6963656e7365)](//packagist.org/packages/shaburov/laravel-crud-rest-api)

Intro and install
-----------------

[](#intro-and-install)

This package created for create fast crud operations, for example Pagination,Object list without pagination, Store, Update, Destroy and Show

```
composer require shaburov/laravel-crud-rest-api

```

Console
-------

[](#console)

```
Publish config
php artisan vendor:publish --provider="CrudRestApi\CrudServiceProvider"
Run controller tests
php artisan crud-rest-api:test
Run migrations
php artisan crud-rest-api:migrate {param_from_migrate}

```

You can activate default routes in config and will see how it's working load\_routes =&gt; true on default false And execute command php artisan route:list

How to use it
-------------

[](#how-to-use-it)

Create Controller and extends it from CrudBaseController or create your Controller on based interfaces and traits and connect your model using method setModelClass

```
abstract class MyController extends CrudController implements
    CrudSaveInterface, CrudIndexInterface,
    CrudStoreInterface, CrudListInterface,
    CrudUpdateInterface, CrudDestroyInterface,
    CrudRestoreInterface, CrudShowInterface
{
    use CrudListTrait,
        CrudIndexTrait,
        CrudStoreTrait,
        CrudIndexTrait,
        CrudUpdateTrait,
        CrudRestoreTrait,
        CrudDestroyTrait,
        CrudSaveTrait,
        CrudShowTrait;

    abstract public function setModelClass(): string;
}

class ArticleController extends MyController
{
    public function setModelClass(): string
    {
        return Article::class;
    }
}

```

Validations
-----------

[](#validations)

You should use CrudValidatorInterface and use Trait CrudValidatorTrait And in method setValidations connect your validations

```
public function setValidations(): void
{
   $this->validateShow = ArticleShowRequest::class;
   $this->validateStore = ArticleStoreRequest::class;
   $this->validateIndex = null;
   $this->validateList = null;
   $this->validateUpdate = null;
   $this->validateDelete = null;
}

```

Change behavior
---------------

[](#change-behavior)

```
All methods include in yourself methods
for change default behaviors

public function beforeList();
public function afterList();

public function updating()
public function updated($model)

public function creating()
public function created($model)

public function saving()
public function saved($model)

public function beforeIndex()
public function afterIndex()

public function beforeShow()
public function afterShow()

public function deleting()
public function deleted()

```

[Controller example](https://github.com/ishaburov/crud-rest-api/blob/master/src/CrudRestApi/Http/Controllers/ArticleController.php)

Routes
------

[](#routes)

You should add routes in your routes file

```
Route::namespace('App\Http\Controllers')->group(function (){
    Route::resource('articles', 'ArticleController');
});

```

Parameters
----------

[](#parameters)

```
index [GET] include parameters
page - current page // articles?page=1
per_page - number of objects in the list // articles?per_page=1
list - for get all object // articles?list

```

You can use $this-&gt;request and process it in behaviors

```
 public function beforeIndex(): void
 {
     $title =  $this->request->get('title');
     $this->state
         ->select(['id','title','category_id',])
         ->where('title', $title)
         ->with('category:id,title');
 }

 or use $this->requestData and get parameter and rewrite it

 public function updating(): void
 {
     $this->requestData['title'] = Str::lower($this->requestData['title']);
 }

```

Config
------

[](#config)

```
'load_routes' => false,
'migration_dir' => database_path()."/migrations/crud" // path export migrations - not required ,
'per_page' => [
        'key' => 'per_page', // key for get parameter
        'value' => 10, // default value
        'limit' => 100, // max value
],

```

In the future
-------------

[](#in-the-future)

#### Generating controllers

[](#generating-controllers)

#### Limits on the number of pages for all Controllers separately

[](#limits-on-the-number-of-pages-for-all-controllers-separately)

#### And more...

[](#and-more)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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

Every ~206 days

Total

5

Last Release

1243d ago

PHP version history (2 changes)1.0.0.x-devPHP ^7.4

v1.1.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/f3fc58bce43457a6536410c57edf58be2e69fc50cc6e15222f236836dcfa4f32?d=identicon)[nkfrez](/maintainers/nkfrez)

---

Top Contributors

[![ishaburov](https://avatars.githubusercontent.com/u/33578398?v=4)](https://github.com/ishaburov "ishaburov (20 commits)")

---

Tags

apilaravelcrudREST API

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/shaburov-laravel-crud-rest-api/health.svg)

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

###  Alternatives

[gdebrauwer/laravel-hateoas

Expose the authorization logic of your REST API using HATEOAS links on your Laravel API resources

17389.4k](/packages/gdebrauwer-laravel-hateoas)[okami101/laravel-admin

Admin panel generator for Laravel 8 and based on Vuetify Admin, a separate SPA admin framework running on top of REST APIs.

382.1k](/packages/okami101-laravel-admin)

PHPackages © 2026

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