PHPackages                             scrumble-nl/laravel-csr - 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. [Database &amp; ORM](/categories/database)
4. /
5. scrumble-nl/laravel-csr

ActiveLibrary[Database &amp; ORM](/categories/database)

scrumble-nl/laravel-csr
=======================

This package makes it possible to generate a controller, service, repository, model and migration all in 1 command

10.2.0(1y ago)4219.2k↓34.4%8[1 issues](https://github.com/scrumble-nl/laravel-csr/issues)[1 PRs](https://github.com/scrumble-nl/laravel-csr/pulls)MITPHPPHP &gt;=8.1CI failing

Since Jun 29Pushed 1y agoCompare

[ Source](https://github.com/scrumble-nl/laravel-csr)[ Packagist](https://packagist.org/packages/scrumble-nl/laravel-csr)[ Docs](https://github.com/scrumble-nl/laravel-csr)[ RSS](/packages/scrumble-nl-laravel-csr/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (11)Used By (0)

Laravel CSR
===========

[](#laravel-csr)

CSR stands for Controller/Service/Repository. This package lets you set all that up with just a single command, with the additional options to disable one of the three layers or even generate a model and/or migration automatically aswell.

Usage
-----

[](#usage)

### Installation

[](#installation)

Install the package using composer:

```
composer require scrumble-nl/laravel-csr

```

Publish the configuration file for default class paths:

```
php artisan vendor:publish --tag=laravel-csr

```

It is possible to modify the default class paths in this newly created `csr.php` config file.

### Command usage

[](#command-usage)

The base command is `php artisan csr:gen {name} {namespace (optional)}`.

This will generate a controller, service interface, service, repository interface and repository all at once. They automatically are dependency injected into eachother so they are ready for usage immediately. Nice!

Finally, you need to add the generated service and/or repository to your `AppServiceProvider.php`.

#### Example

[](#example)

`php artisan csr:gen picture holiday`will generate the following files:

- `app/Http/Controllers/Holiday/PictureController.php`
- `app/Interfaces/Services/Holiday/IPictureService.php`
- `app/Services/Holiday/PictureService`
- `app/Interfaces/Repositories/Holiday/IPictureRepository`
- `app/Repositories/Holiday/PictureRepository`

**Note**: The command will automatically capitalize the first character, so `picture` will become `Picture`. If you want your classes to have a name like `PictureBook` you will have to type this correctly yourself.

Now you will need to register your service and repository:

AppServiceProvider.php:

```
