New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

nordcoders/laravel-service-maker

Generate services and contracts in Laravel with the artisan command
1,491 26
Install
composer require nordcoders/laravel-service-maker
Latest Version:v1.0.1
PHP:^8.1
Laravel:9
License:MIT
Last Updated:Oct 9, 2023
Links: GitHub  ·  Packagist
Maintainer: ludoguenet

Laravel Service Maker

Total Downloads Latest Stable Version License

What does it do?

This package adds a new php artisan make:service {name} {--N|noContract} command. It will create a service file and its contract (interface) for saving time while working with Laravel Framework and benefit from the Service Pattern.

Installation

You can install the package via composer:

composer require nordcoders/laravel-service-maker --dev

How does it work?

After installation, the command php artisan make:service {name} {--N|noContract} will be available.

Create services files

For example, the command php artisan make:service createUser will generate a service file called CreateUserService.php located in app/Services/CreateUser.

It will also generate an interface (contract) called CreateUserContract.php located in app/Services/Contracts.

Create services for models

Adding a --service or -S option is now available when creating a model.

For example, the command php artisan make:model Book --service or php artisan make:model Book -S will generate a model with service too.

The command php artisan make:model Book --all or php artisan make:model Book -a will now generate a model, migration, factory, seeder, policy, controller, form requests and service.

Contracts

Adding a --noContract or -N option will prevent the commands from implementing any contract and will not create any contract file.

If you never need any contracts. Publish the config file and then turn the with_interface value to false in the config file.

Configuration file

You can publish the config file with:

php artisan vendor:publish --tag="service-maker-config"

This is the content of the published config file:

return [
    'with_interface' => true,
];

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

648,266,899 9,701
laravel/framework

The Laravel Framework.

604,216,237 34,982
laravel/tinker

Powerful REPL for the Laravel framework.

512,508,631 7,443
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

429,221,767 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

407,699,310 4,663

Version History

Version Released PHP Laravel License
v1.0.1 ^8.1 ^9.0 MIT
v1.0.0 ^8.1 ^9.0 MIT