Download the PHP package teksite/handler without Composer
On this page you can find all versions of the php package teksite/handler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download teksite/handler
More information about teksite/handler
Files in teksite/handler
Package handler
Short Description Some features to work with error handling in Laravel codes
License MIT
Informations about the package handler
Handler Package
About
A lightweight Laravel package designed to simplify common PHP and Laravel operations, including try-catch handling, database querying, and other utility functions.
Table of Contents
- About
- Author
- Contact
- Installation
- Features
- Support
About
The Handler Package streamlines development by providing helper functions for managing try-catch blocks, fetching data from databases, and other common tasks in PHP and Laravel applications. It aims to reduce boilerplate code and improve code readability.
Author
Developed by Sina Zangiband.
Contact
- Website:
- Email: [email protected]
Installation
Step 1: Install via Composer
Run the following command in your terminal:
Step 2: Register the Service Provider
For Laravel > 9
Add the service provider to the bootstrap/providers.php file:
Note: Laravel 5.5 and above supports auto-discovery, so this step is not required for newer versions.
Features
Simplify exception handling.
example:
- in this code :
do()is necessary, and it is your main code to be processed in try-catchifFailedis run if your code fails, the error is log in laravel.log- you can ignore error handling by setting
$withHandler false:ServiceWrapper::make(withHandler: false) - by default db transaction is active to set it off :
ServiceWrapper::make(hasTransaction: false) - also by default the output of the
doand isifFailedis instance ofServiceResultto have integrated result. set it off byServiceWrapper::make(wrapServiceResult: false) - all these configs can be set globally in
handler-settings.transactionconfig file
Streamlined methods for querying and fetching data.
example of ServiceWrapper and FetchDataService
-
in this code:
- you can only use
FetchDataService::get(Post::class, ['title'], ...$fetchData)without ServiceWrapper class. - the arguments of this method are:
string|Closure|Builder|Relation $model: to get query from class or relation or model,`string|array|Closure|null $searchColumns: search in column, to implement operators you can$searchColumns = [['column'=>'title' , 'operator'=>'LIKE' ] , ['category'=>'='],array $only = ['*']: select desired columns,null|int|false $perPage = null: number of records per page (can be changed in handler-settings.pagination config file),null|false|int $limitPagination = null: it is used to limit client to get large amount records per page ( can be change in handler-settings.limit-pagination config file)
- you can only use
Response by json or http
Configuration
The package includes a configuration file for customization. Publish it using:
Edit the configuration in config/handler-settings.php to adjust settings like default query limits or error logging.
Support
For questions, issues, or feature requests, please reach out via:
- Website: teksite.net
- Email: [email protected]
- GitHub Issues: teksite/handler
Contributions are welcome! Feel free to submit a pull request or open an issue on GitHub.