PHPackages                             apriandanailus/cruder - 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. [CLI &amp; Console](/categories/cli)
4. /
5. apriandanailus/cruder

ActiveLibrary[CLI &amp; Console](/categories/cli)

apriandanailus/cruder
=====================

CRUD artisan

01PHP

Since Aug 27Pushed 6y ago1 watchersCompare

[ Source](https://github.com/apriandanailus/cruder)[ Packagist](https://packagist.org/packages/apriandanailus/cruder)[ RSS](/packages/apriandanailus-cruder/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

CRUD artisan command
====================

[](#crud-artisan-command)

Creates a Model, Controller (with Repository, validation Requests, Events and Listeners), Migration, Routes, Breadcrumbs and CRUD Views for the given name ready to work in \[backend.

From version 1.4 you can also optionally generate frontend files: Controller, Labels, Event, Request, Listener, View, Route and Repository.

By default it does not overwrite any files that may exist with the pre-stablished names. So, if you delete one of the files and run the command again, the deleted file will be created again and the rest will be ignored and will keep the changes you could have made.

Requires
--------

[](#requires)

- [Laravel 5](https://laravel.com)
-

It has been tested with Laravel 5.7.

Install
-------

[](#install)

```
composer require apriandanailus/cruder

```

Run
---

[](#run)

In your Laravel project root folder:

```
php artisan l5b:crud example

```

Where *example* is the name you want for your model (routes, views, controllers,...). I've tried to follow best naming practices and it uses plural or singular names and lower or uppercase where needed. You can also use camelCase or snake\_case.

Parameters *example*, *Example*, *examples* or *EXAMPLES* all give the same results.

Then run the created migration:

```
php artisan migrate

```

In your browser open:

```
https://YOUR_SITE/admin/examples

```

**...et voilà! :)**

Note: out of the box, the table comes only with a *title* text field, besides the *id*, *deleted\_at*, *created\_at* and *updated\_at*. Edit your newly created migration file to add any other you may need before runnning the migrate command.

Options
-------

[](#options)

You can create all the files and run the migration by running the command with the --migrate option:

```
php artisan l5b:crud example --migrate

or

php artisan l5b:crud example -m

```

You may also specify the name of the default text field 'title' to whatever other you prefer with the --field option:

```
php artisan l5b:crud example --field=name

or

php artisan l5b:crud example -f name

```

You can also overwrite previously created files with the --force option.

```
php artisan l5b:crud example --force

```

To generate the frontend files also, you should use the --frontend option.

```
php artisan l5b:crud example --frontend

```

Include a menu item
-------------------

[](#include-a-menu-item)

A file named *sidebar-examples.blade.php* is created in the folder */resources/views/backend/example/includes*. It contains the html code for a menu item to access your recently created views. You can show it in your sidebar by including the following line in */resources/views/backend/includes/sidebar.blade.php* wherever you want it to appear:

```
@include('backend.example.includes.sidebar-examples')

```

Events and Listeners
--------------------

[](#events-and-listeners)

The package generates three events and listeners for creating, updating and deleting items methods. In order to get these to work you must resgister them with the event dispatcher, adding this line to your *Providers/EventServiceProvider.php* file (under *Backend Subscribers*):

```
\App\Listeners\Backend\Example\ExampleEventListener::class

```

Language lines
--------------

[](#language-lines)

Customized English language lines can be found */resources/lang/en*. There is a file for backend lines (backend\_examples.php) and another for frontend (frontend\_examples.php).

Backend Files created
---------------------

[](#backend-files-created)

### Model

[](#model)

```
app/Models/Example.php

```

### Trait Attribute

[](#trait-attribute)

```
app/Models/Traits/Attribute/ExampleAttribute.php

```

This is where the action buttons for the new object are.

### Controller

[](#controller)

```
app/Http/Controllers/Backend/ExampleController.php

```

It contains the CRUD methods: *index*, *create*, *store*, *show*, *edit*, *update*, *destroy*, *delete*, *restore* and *deleted*.

### Repository

[](#repository)

```
app/Repositories/Backend/ExampleRepository.php

```

Contains database logic.

### Requests

[](#requests)

```
app/Http/Requests/Backend/ManageExampleRequest.php
app/Http/Requests/Backend/StoreExampleRequest.php
app/Http/Requests/Backend/UpdateExampleRequest.php

```

Validation manage, store and update Requests.

### Events

[](#events)

```
app/Events/Backend/Example/ExampleCreated.php
app/Events/Backend/Example/ExampleUpdated.php
app/Events/Backend/Example/ExampleDeleted.php

```

### Listeners

[](#listeners)

```
app/Listeners/Backend/Example/ExampleEventListener.php

```

### Migrations

[](#migrations)

```
database/migrations/\YYYY_MM_DD_create_examples_table.php

```

### Routes

[](#routes)

```
routes/backend/examples.php

```

Contains the named routes *admin.examples.index*, *admin.examples.deleted*, *admin.examples.restore*, *delete-permanently*, *admin.examples.create*, *admin.examples.store*, *admin.examples.show*, *admin.examples.edit*, *admin.examples.update* and *admin.examples.destroy*.

### Breadcrumbs

[](#breadcrumbs)

```
routes/breadcrumbs/backend/example.php

```

This has the breadcrumbs for the routes *admin.examples.index*, *admin.examples.create*, *admin.examples.show*, *admin.examples.edit* and *admin.examples.deleted*.

The following line is added to *routes/breadcrumbs/backend/backend.php*:

```
require **DIR**.'/example.php';

```

If you delete the *routes/breadcrumbs/backend/example.php* file created by this command, don't forget to delete this line or your whole project will crash.

### Views

[](#views)

```
resources/views/backend/example/index.blade.php
resources/views/backend/example/show.blade.php
resources/views/backend/example/create.blade.php
resources/views/backend/example/edit.blade.php
resources/views/backend/example/deleted.blade.php
resources/views/backend/example/includes/breadcrumb-links.blade.php
resources/views/backend/example/includes/header-buttons.blade.php

```

If you add more fields to your datatable, you'll have to edit *show.blade.php*, *create.blade.php* and *edit.blade.php* to suit your needs.

### Menu item

[](#menu-item)

```
sidebar-examples.blade.php

```

HTML code for the menu item for your Laravel 5 Boilerplate sidebar.

Fronted Files created
---------------------

[](#fronted-files-created)

### Controller

[](#controller-1)

```
app/Http/Controllers/Frontend/ExampleController.php

```

It contains the CRUD methods: *index*, *create*, *store*, *show*, *edit*, *update*, *destroy*, *delete*, *restore* and *deleted*.

### Repository

[](#repository-1)

```
app/Repositories/Frontend/ExampleRepository.php

```

Contains database logic.

### Requests

[](#requests-1)

```
app/Http/Requests/Frontend/ManageExampleRequest.php
app/Http/Requests/Frontend/StoreExampleRequest.php
app/Http/Requests/Frontend/UpdateExampleRequest.php

```

Validation manage, store and update Requests.

### Events

[](#events-1)

```
app/Events/Frontend/Example/ExampleCreated.php
app/Events/Frontend/Example/ExampleUpdated.php
app/Events/Frontend/Example/ExampleDeleted.php

```

### Listeners

[](#listeners-1)

```
app/Listeners/Frontend/Example/ExampleEventListener.php

```

### Routes

[](#routes-1)

```
routes/frontend/examples.php

```

Contains the named routes *examples.index*, *examples.deleted*, *examples.restore*, *delete-permanently*, *examples.create*, *examples.store*, *examples.show*, *examples.edit*, *examples.update* and *examples.destroy*.

### Views

[](#views-1)

```
resources/views/frontend/example/index.blade.php
resources/views/frontend/example/show.blade.php
resources/views/frontend/example/create.blade.php
resources/views/frontend/example/edit.blade.php
resources/views/frontend/example/deleted.blade.php
resources/views/frontend/example/includes/header-buttons.blade.php

```

If you add more fields to your datatable, you'll have to edit *show.blade.php*, *create.blade.php* and *edit.blade.php* to suit your needs.

Changes
-------

[](#changes)

- **1.4** Added language lines files. Added options for frontend file generation and force overwriting of previous files. Thanks @rabol for your contribution.
- **1.3.8** Modified README.md about adding Listener to EventServiceProvider.php.
- **1.3.7** Added event firing to controller methods.
- **1.3.6** Added Events and Listeners for Create, Update and Delete operations.
- **1.3.5** Added --field option to specify the name of the default field

License
-------

[](#license)

This repository is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

Copyright © 2019 Apriandanailus

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

**Laravel** Copyright © 2019 Taylor Otwell

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2537cb66d59ca1e59c03377cdc8cb91e45a3b2f7fc24e85700782a5040d4d714?d=identicon)[apriandanailus](/maintainers/apriandanailus)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/apriandanailus-cruder/health.svg)

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

###  Alternatives

[wp-cli/wp-cli

WP-CLI framework

5.0k17.2M320](/packages/wp-cli-wp-cli)[consolidation/annotated-command

Initialize Symfony Console commands from annotated command class methods.

22569.8M18](/packages/consolidation-annotated-command)[chi-teck/drupal-code-generator

Drupal code generator

26947.8M5](/packages/chi-teck-drupal-code-generator)[seld/cli-prompt

Allows you to prompt for user input on the command line, and optionally hide the characters they type

24725.8M17](/packages/seld-cli-prompt)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[php-tui/php-tui

Comprehensive TUI library heavily influenced by Ratatui

589747.0k6](/packages/php-tui-php-tui)

PHPackages © 2026

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