Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/calsranna/rsp
RSP Architecture for Laravel.
https://github.com/calsranna/rsp
composer laravel rsp-architecture
Last synced: about 1 month ago
JSON representation
RSP Architecture for Laravel.
- Host: GitHub
- URL: https://github.com/calsranna/rsp
- Owner: CalsRanna
- Created: 2017-03-03T18:32:20.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-04T04:14:23.000Z (over 6 years ago)
- Last Synced: 2024-05-01T02:04:25.598Z (9 months ago)
- Topics: composer, laravel, rsp-architecture
- Language: PHP
- Homepage:
- Size: 33.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# RSP
## About RSP
RSP is a web application library used to make things easier while you building a plain Laravel application.
Besides, it provides some efficient commands to let you free while you're coding.RSP is short for **Repository Service and Presenter**.
## How to use
### Installation
You can run `composer require cals/rsp` to install RSP from
[Packagist](https://packagist.org/packages/cals/rsp).Or, you can add `"cals/rsp": "~2.0"` to your `composer.json` and then run `composer update` in your
terminal to install it.### Configuration
After you install the RSP, you should put `Cals\RSP\RSPServiceProvider::class` in your
`config/app.php` providers array to make it work.> If you use Laravel 5.5 and after, you don't need do it cause laravel will auto load the provider.
Then you should run `php artisan vendor:publish --tag=rsp` to publish `rsp.php`.
### Usage#### Repository
You can use `make:repository` to create a repository and its' interface, or you can create them manually if
you want to. Remember that the repository should extends `Cals\RSP\Repositories\Implementations\Repository`
if you create it manually.The repository is like below:
```php
While the returned value has only one record when you use `get(array $columns = ['*'],array $crendentials = null)`,
it is still an instance of `Illuminate\Database\Eloquent\Collection`. So if you want to find only one record and wish
its' type is `Illuminate\Database\Eloquent\Model`, you can use `find(array $credentials = null)` or finish it yourself
using the method `builder()` we provided.While we use RSP, we do not use repository directly in controller. Repository should always provide methods to let
service to use it.#### Service
You can use `make:service` to create a service and its' interface, or you can create them manually if you want to.
Remember that the service should extends
`Cals\RSP\Services\Implementations\Service` if you create it manually.The service is like below:
```php
repository = $repository;
}// Put your code here...
}```
And the interface is like below:
```php
[],/*
|--------------------------------------------------------------------------
| Services
|--------------------------------------------------------------------------
|
| This array is the list of your service. The key should be the full name
| of interface and the value should be the full name of implementation.
*/'services' => [],
/*
|--------------------------------------------------------------------------
| Presenters
|--------------------------------------------------------------------------
|
| This array is the list of your presenter. The key should be the full name
| of interface and the value should be the full name of implementation.
*/
'presenters' => []
];
```Such as:
```php
'repositories' => [
'App\Repositories\Interfaces\ExampleRepositoryInterface' => 'App\Repository\Implementations\ExampleRepository'
],
```Then Laravel can bind the interface on the implementation.
### Commands
We provide some commands for you to create files which have some basic codes, and you can put your own code into it to
satisfy your needs.The commands list below:
* `make:repository` You can use it to create repository class and its' interface.
* `make:service` You can use it to create service class and its' interface.
* `make:presenter` You can use it to create presenter class and its' interface.
* `rsp:generate` You can use it to generate repositories, services and presenters based on registration.## Contributing
Thank you for considering contributing to the RSP Architecture library!
## Author
Cals Ranna
## License
The RSP Architecture is an open-sourced library licensed under the [MIT license](http://opensource.org/licenses/MIT).