Download the PHP package aslaluroba/babylai_php_auth_client without Composer
On this page you can find all versions of the php package aslaluroba/babylai_php_auth_client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aslaluroba/babylai_php_auth_client
More information about aslaluroba/babylai_php_auth_client
Files in aslaluroba/babylai_php_auth_client
Package babylai_php_auth_client
Short Description A simple PHP client for BabylAI Auth API (get client token)
License MIT
Informations about the package babylai_php_auth_client
BabylAI PHP Auth Client
A simple PHP library to fetch a client token from the BabylAI Auth API. It wraps a single endpoint:
by accepting a Tenant ID (UUID) and API key, returning a JSON payload containing token and expiresIn.
Table of Contents
- Features
- Requirements
- Installation
- Usage
- Standalone PHP Example
- Laravel Integration
- Configuration
- Contributing
- License
Features
- PSR-4 autoloading: simply
requirevia Composer. - Guzzle-powered: uses Guzzle HTTP under the hood.
- Lightweight: only two DTO classes plus the client wrapper.
- Error handling: throws an exception if the HTTP request fails or the response is invalid.
Requirements
- PHP >= 7.4
ext-curl/ext-opensslenabled (for HTTPS)- Guzzle 7.x (installed via Composer)
Installation
-
Ensure you have Composer installed on your system:
-
Require this package
This will pull in Guzzle as well and configure PSR-4 autoloading for BabylAI* classes.
- Verify that vendor/aslaluroba/babylai_php_auth_client exists and that vendor/autoload.php was updated.
Usage
Below are two common ways to use this client:
Standalone PHP Example
Create a simple test.php in any folder outside Laravel:
Run it:
If credentials are valid, you'll see:
Otherwise, you'll get an exception message.
Laravel Integration
Below is a minimal Laravel 12 example showing how to create an endpoint /api/Token that returns { token, expiresIn }:
-
Install in a Laravel project
From your Laravel app root:
-
Create configuration file
Create
config/babylai.phpwith:Add these to
.env:Run:
-
Bind the client in the container
Open
app/Providers/AppServiceProvider.php, and in theregister()method add:Save the file.
-
Create the controller
Generate a controller:
Edit
app/Http/Controllers/Api/TokenController.php: -
Register the route
If
routes/api.phpdoes not exist, create it. Inroutes/api.php, add:Note: This registers
/api/Token(capital "T"). If you prefer lowercase, use 'token' instead of 'Token'.Run:
You should see:
-
Configure CORS
Create
config/cors.php(if it doesn't exist) with:Ensure
\Fruitcake\Cors\HandleCors::classis inapp/Http/Kernel.phpunder$middleware. Then run: -
Serve over HTTPS on port 7075
If you have the Symfony CLI installed, in a new terminal:
This auto‐generates a local TLS certificate. It will show:
Open your browser at:
Accept the (self-signed) certificate, and you'll see:
Your Angular app at
https://localhost:4200can now fetch fromhttps://localhost:7075/api/Tokenwithout CORS issues.
Configuration
-
composer.json(defaults for your package) -
.env(in Laravel) must have: -
config/babylai.phplives in Laravel'sconfig/folder. -
config/cors.phpwhitelists your front‐end origins. - Your route (
api/Token) is registered exactly as uppercase "Token" if you need that URL shape.
Contributing
Fork the repository on GitHub: https://github.com/your-vendor/babylai-php-auth-client
Create a feature branch:
Commit your changes, respecting PSR-12 formatting.
Push to your fork and submit a Pull Request.
We use semantic versioning (v1.0.0, v1.1.0, etc.). Tag new releases accordingly.
License
AAU