yangze / laravel-modules-helper
some command help for caffeinated/modules
Package info
github.com/zhenyangze/laravel-modules-helper
pkg:composer/yangze/laravel-modules-helper
v0.1.7
2019-12-17 16:08 UTC
Requires
- php: >=7.0.0
- caffeinated/modules: *
- illuminate/support: ^5.5,<5.8
README
this is a package for creating restful api with nwidart/laravel-modules, the first version is aim to create restful api in modules.
Quick Installation
Begin by installing the package through Composer.
composer require yangze/laravel-modules-helper
Once this operation is complete, simply add both the service provider and facade classes to your project's config/app.php file:
Service Provider
Yangze\ModulesHelper\ModulesHelperServiceProvider::class,
publish tag
php artisan vendor:publish --tag Yangze\ModulesHelper\ModulesHelperServiceProvider
Command list
| command | description | args |
|---|---|---|
| module:api | Create a new module Controller class | --model |
Usage
- create modules, such as Common
php artisan make:module Common
- create restfull api
before you create the api, you shoule make sure the model is exists.
php artisan module:api common Api/CommonNewsController --model App\\Models\\CommonNews
- add route to the
api.php
in my website is app/Modules/Common/Routes/api.php,you should choose the right module.
Route::resource('common/news', 'CommonNewsController');
- test the restful api
| method | url | comment |
|---|---|---|
| get | api/common/news | |
| post | api/common/news | form |
| get | api/common/news/1 | |
| put | api/common/news/1 | raw |
| delete | api/common/news/1 |