oanhnn/laravel-handlers

Using handler class instead of controller class in Laravel 5.5+ application

v1.0.1 2019-11-23 07:35 UTC

This package is auto-updated.

Last update: 2024-10-23 19:39:30 UTC


README

Latest Version Software License Build Status Coverage Status Total Downloads Requires PHP

Using handler class instead of controller class in Laravel 5.5+

Requirements

  • php >=7.1.3
  • Laravel 5.5+

Laravel 6.0+ requires php 7.2+

Installation

Begin by pulling in the package through Composer.

$ composer require oanhnn/laravel-handlers

Laravel

After that, publish vendor's resources:

$ php artisan vendor:publish --tag=laravel-handlers-config

Lumen

After that, copy the config file from the vendor directory:

$ cp vendor/oanhnn/laravel-handlers/config/handlers.php config/handlers.php

Update base handler class to your class in config/handlers.php.
Register the config file and the service provider in bootstrap/app.php:

$app->configure('handlers');

$app->register(Laravel\Handlers\ServiceProvider::class);

Usage

Create handler class

Create new handler class by run command

$ php artisan make:handler ShowProfile

You can use --force option to force create handler class (override existed class)

$ php artisan make:handler --force ShowProfile

Configure

You can change namespace of handler classes by config namespace in config/handlers.php file.

    'namespace' => '\\App\\Http\\Api',

You can change base handler class by config base in config/handlers.php file.

    'base' => '\App\Http\Controllers\Controller::class',

Customize handler stub

If you want customize stub file, please run:

$ php artisan vendor:publish --tag=laravel-handlers-stubs

Changelog

See all change logs in CHANGELOG

Testing

$ git clone git@github.com/oanhnn/laravel-handlers.git /path
$ cd /path
$ composer install
$ composer phpunit

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email to Oanh Nguyen instead of using the issue tracker.

Credits

License

This project is released under the MIT License.
Copyright © Oanh Nguyen.