Download the PHP package iqbalatma/laravel-utils without Composer
On this page you can find all versions of the php package iqbalatma/laravel-utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-utils
Laravel Utils
Laravel utils is collection of class, helper, command console for help you to efficiency your development time. Here we have command console for generate enum, abstract, interface, or trait
Config
Target dir is where generated file root path. Change this target dir location by your preference.
Generate File Command
You can generate enum with this utils You can also create backed enum, with string or int as type
Enum
You can generate trait with this command
Trait
You can generate abstract with this command
Abstract
You can generate interface with this command
Interface
Publish Stub File
In some condition you may publish stub file and modify template.
Formatting API Response
You can format your api response using this feature. For example :
Description :
- First argument is for data, you can pass paginator, string, array, resource, and null.
- Second argument is for message, data type is string
- Third argument is response code. You can see response code in Iqbalatma/LaravelUtils/ResponseCode
- Forth argument is errors, mostly used for validation errors.
- Fifth argument is for exception, mostly used for mapping execption.
The response would be
You can customize response code (rc) using third argument. You can override to add response code of this class. Just override the class and override mapHttpCode() function. For example you can add response code for ERR_NOT_FOUND()
This is how to handle exception and customize response format:
You can change behavior of json formatting via config file.
- Key is_show_debug use to determine is show exception message or not. This might be cause sensitive information leaks, so do not activate this feature in production environtmen.
- Key api_response.payload used for key of response. You can change wrapper with another wrapper or set null to not using payload wrapper.
- Key api_response.meta_wrapper is used for wrapping data meta. When you using
Helper
ddapi()
You can use ddapi() helper function to dump api data to see data of a variable