Download the PHP package diegoalvarezb/laravel-service-utils without Composer
On this page you can find all versions of the php package diegoalvarezb/laravel-service-utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download diegoalvarezb/laravel-service-utils
More information about diegoalvarezb/laravel-service-utils
Files in diegoalvarezb/laravel-service-utils
Package laravel-service-utils
Short Description Utils for internal Laravel services.
License MIT
Homepage https://github.com/diegoalvarezb/laravel-service-utils
Informations about the package laravel-service-utils
laravel-service-utils
This tool adds some utilities for internal services in Laravel.
Using this package, you could extend all your services (classes with the application business logic) from Diegoalvarezb\ServiceUtils\AbstractService
and use some funcionalities:
- Service response interface
- Log management
Requirements
- PHP >= 5.6
- Laravel >= 5.0
Installation and configuration
Package installation with composer:
And add the service provider in your config/app.php
file:
And this command will add the service-utils config file to the laravel config folder:
Service response interface
Use the next command to return the result of a method:
The first param contains an array with all data. The second one must be the error code (this one must exists in the service-utils config file). The third one an additional message (if you don't send this param, the corresponding in the config file will be selected).
This method will return a ServiceResponse
object, wich has the next methods:
- hasErrors()
- isCritical()
- getMessage()
- getData()
- getHttpCode()
Service log management
Use the next command to write info the log file:
The first param contains the exception. The second one must be the log type. The third one an additional message.
The list of log types:
- error
- emergency
- alert
- critical
- warning
- notice
- info
The structure of the log: [datetime] local.LOG_TYPE: Path\To\Class | method() | (Exception) | message
Example config file: service-utils.php
License
MIT