Download the PHP package jerrydepredator/laravel-predator-api-utils without Composer
On this page you can find all versions of the php package jerrydepredator/laravel-predator-api-utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jerrydepredator/laravel-predator-api-utils
More information about jerrydepredator/laravel-predator-api-utils
Files in jerrydepredator/laravel-predator-api-utils
Package laravel-predator-api-utils
Short Description A collection of utility classes and traits to streamline common Laravel development tasks, including error handling, paginated responses, data handling, middleware creation, a base repository for advanced filtering, keyset pagination, base query filtering, and more. This package aims to reduce boilerplate code often encountered in Laravel projects.
License MIT
Informations about the package laravel-predator-api-utils
Laravel Predator API Utils
This package provides a collection of utility classes and traits to streamline common Laravel development tasks, such as:
- Error Handling: Easily handle and format API errors.
- Paginated Responses: Create paginated responses with consistent structure.
- Data Handling: Simplify data manipulation and extraction.
- Middleware: Implement custom middleware for authentication, authorization, and other cross-cutting concerns.
- Repository Pattern: Provides a base repository class for common database operations.
⚠️⚠️ Disclaimer ⚠️⚠️
This package aims to reduce boilerplate code often encountered in my Laravel projects by providing reusable components. It was created based on my personal preferences and may not be suitable for all projects or development styles. It is not intended to be a comprehensive solution for all Laravel development needs and may require customization for specific requirements.
Installation
-
Install via Composer:
-
Publish Configuration (Optional):
-
If you want to customize the default property names for the
DecryptedJWToken
service, publish the configuration file: - This will create a
config/decrypted_jwt_token.php
file in your project where you can modify the property names.
-
Usage
1. DecryptedJWTToken Service:
- Location:
src/Services/DecryptedJWToken.php
- Purpose: Provides methods to access data from a decrypted JWT token.
- Usage:
2. Middlewares:
-
DecryptJWToken:
- Location:
src/Middlewares/DecryptJWToken.php
- Purpose: Decrypts the JWT token from the
Authorization
header and adds the decrypted data to the request object. -
Usage:
-
Register the middleware in
app/Http/Kernel.php
: - Apply the middleware to routes:
-
- Location:
-
RoleMiddleware:
- Location:
src/Middlewares/RoleMiddleware.php
- Purpose: Restricts access to routes based on user roles.
-
Usage:
-
Register the middleware in
app/Http/Kernel.php
: - Apply the middleware to routes:
-
- Location:
3. Traits:
-
ApiResponse:
- Location:
src/Traits/ApiResponse.php
- Purpose: Provides helper methods for creating API responses with standardized structures.
- Location:
-
HandlesErrors:
- Location:
src/Traits/HandlesErrors.php
- Purpose: Provides helper methods for handling and formatting API errors.
- Location:
- PaginationRules:
- Location:
src/Traits/PaginationRules.php
- Purpose: Provides rules for validating pagination parameters.
- Location:
4. Repositories:
- BaseRepository:
- Location:
src/Repositories/BaseRepository.php
- Purpose: Provides a base class for implementing repositories with common database operations.
- Location:
Configuration:
decrypted_jwt_token.php
:- Located in the
config
directory. - Defines default property names for the
DecryptedJWToken
service. - Can be customized to match your specific JWT token structure.
- Located in the
Contributing
Contributions are welcome! Please submit pull requests to the project's GitHub repository.
License
This package is licensed under the MIT License.
All versions of laravel-predator-api-utils with dependencies
illuminate/http Version ^11.31
illuminate/database Version ^11.31
illuminate/contracts Version ^11.31
firebase/php-jwt Version ^6.10