A Simple Package to create actions, traits and services using artisan commands in laravel.
This package extends the make:
commands to help you easily create traits, action classes and service classes in Laravel 5+. It also comes with the option of creating an interface for the service.
composer require prevailexcel/laravel-action-service-trait
Or add the following line to the require block of your composer.json
file.
"prevailexcel/laravel-action-service-trait": "1.0.*"
You'll then need to run composer install
or composer update
to download it and have the autoloader updated.
Once it is installed, you can use any of the commands in your terminal.
php artisan make:action {name}
php artisan make:service {name}
php artisan make:service {name} --i
php artisan make:trait {name}
$ php artisan make:action CreateUser
/app/Actions/CreateUser.php
<?php
namespace App\Actions;
/**
* Class CreateUser
* @package App\Services
*/
class CreateUser
{
/**
* @return true
*/
public function execute(){
// write your code here
return true;
}
}
php artisan make:service PostService --i
/app/Services/PostService.php
<?php
namespace App\Services;
use App\Services\Interfaces\PostServiceInterface;
/**
* Class PostService
* @package App\Services
*/
class PostService implements PostServiceInterface
{
}
/app/Services/Interfaces/PostUserInterface.php
<?php
namespace App\Services\Interfaces;
/**
* Interface PostServiceInterface
* @package App\Services\Interfaces
*/
interface PostServiceInterface
{
}
/app/Traits/UploadImage.php
$ php artisan make:trait UploadImage
<?php
namespace App\Traits;
/**
* Trait UploadPhoto
* @package App\Traits
*/
trait UploadPhoto
{
}
Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.
Why not star the github repo? I'd love the attention! Why not share the link for this repository on Twitter or HackerNews? Spread the word!
Don't forget to follow me on twitter! Also check out my page on medium to catch articles and tutorials on Laravel follow me on medium!
Thanks! Chimeremeze Prevail Ejimadu.
The MIT License (MIT). Please see License File for more information.