Download the PHP package omaralalwi/laravel-api-helpers without Composer
On this page you can find all versions of the php package omaralalwi/laravel-api-helpers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download omaralalwi/laravel-api-helpers
More information about omaralalwi/laravel-api-helpers
Files in omaralalwi/laravel-api-helpers
Download omaralalwi/laravel-api-helpers
More information about omaralalwi/laravel-api-helpers
Files in omaralalwi/laravel-api-helpers
Vendor omaralalwi
Package laravel-api-helpers
Short Description collection of helpful helper functions for API Requests .
License MIT
Homepage https://github.com/omaralalwi/laravel-api-helpers
Package laravel-api-helpers
Short Description collection of helpful helper functions for API Requests .
License MIT
Homepage https://github.com/omaralalwi/laravel-api-helpers
Keywords i18napiversioninglaravellocalizationinternationalizationapi-developmentcontent-negotiationrest-apilaravel-developmentlaravel-packageapi-responsedeveloper-toolsrestful-apiLaravel-Utilitiesphp-packagesecurity-headersapi-securityhttp-requestsapi-toolsapi-authenticationapi-versioningjson-responselaravel-developerclient-iplaravel-api-helperssemantic-versioningrequest-helpersrequest-handlingbearer-authenticationip-detectionapi-middlewareheader-parsingbearer-tokenapi-user-management
Please rate this library. Is it a good library?
Informations about the package laravel-api-helpers
Laravel API Helpers π
Laravel API Helpers is a collection of helper functions designed to streamline API development with Laravel. It enables you to easily detect API versions, validate requests, and access useful request detailsβall while keeping your code clean and maintainable. β¨
## π Features - **API Version Detection:** Determine the API version from the request URL or headers. - **API Version Validation:** Check if the current request matches or exceeds a specified API version. - **API Request Identification:** Identify if a request is targeting the API. - **Request Helpers:** Retrieve client IP, locale, token, content type, headers, and check for secure requests. - **Authentication Helpers:** Determine API authentication status and retrieve the authenticated user. ## π Requirements - PHP 7.4 or higher - Laravel 7.x or higher ## π οΈ Installation Install the package via Composer: ## π¦ Usage The helper functions are globally available throughout your Laravel application. You can call them anywhereβcontrollers, middleware, or routes or blade files. --- ## π API Helper Functions Guide ### π . `get_api_v()` Extracts the API version from the current request by inspecting the URL (e.g., `api/v4`) or the `Accept-Version` header. --- ### β . `is_api_v($version)` Determines if the current request is for a specific API version by comparing the detected version with the provided one. --- ### β« . `api_v_at_least($version)` Checks whether the current API version is at least a specified minimum version. --- ### π . `is_api_request()` Determines whether the current request is an API request by examining the URL, expected JSON responses, and the presence of specific API headers. --- ### π‘ . `get_client_ip()` Retrieves the client's IP address from the current request. --- ### π . `get_request_locale()` Gets the locale from the request's `Accept-Language` header. If not provided, it defaults to the application's locale. --- ### π . `get_request_token()` Returns the bearer token from the current request's authorization header. --- ### π . `get_request_content_type()` Retrieves the `Content-Type` header from the current request. --- ### π . `is_secure_request()` Checks whether the current request is made over a secure HTTPS connection. --- ### π . `get_request_headers()` Returns all headers from the current request as an associative array. --- ### π . `is_api_authenticated()` Determines whether the API user is authenticated using the `api` guard. --- ### π€ . `get_auth_user()` Retrieves the authenticated user from the default authentication guard. --- ### π₯ . `get_api_user()` Returns the authenticated user using the `api` guard. --- ### Comprehensive Example For All Functions copy & past following block, then see outputs in log file --- ## Changelog See [CHANGELOG](CHANGELOG.md) for recent changes. ## Contributors β¨ Thanks to these wonderful people for contributing to this project! π
Omar Al Alwi π Creator |











All versions of laravel-api-helpers with dependencies
PHP Build Version
Package Version
Requires
php Version
^7.4|^8.0
The package omaralalwi/laravel-api-helpers contains the following files
Loading the files please wait ....