theafolayan / 100ms-laravel
A Laravel SDK for 100ms API.
Requires
- php: ^8.0
- firebase/php-jwt: ^6.0
- guzzlehttp/guzzle: ^7.0
- illuminate/support: ^8.0|^9.0|^10.0
- ramsey/uuid: ^4.7
Requires (Dev)
- phpunit/phpunit: ^11.5
README
The 100ms Laravel SDK provides an easy way to integrate the 100ms API with your Laravel application. It includes features for room management, generating room codes, and managing 100ms resources through secure management tokens.
Features
- Generate and manage rooms.
- Generate room codes for prebuilt apps.
- Secure authentication with management tokens.
- Easy integration with Laravel through service providers and facades.
Installation
1. Install the Package
Add the package to your Laravel project using Composer:
composer require theafolayan/100ms-laravel
2. Publish Configuration
Publish the configuration file to set your 100ms API credentials:
php artisan vendor:publish --provider="TheAfolayan\HmsLaravel\HmsServiceProvider"
This will create a config/100ms.php
file.
Configuration
Add your 100ms API credentials to your .env
file:
HMS_API_KEY=your_api_key HMS_API_SECRET=your_api_secret HMS_BASE_URL=https://api.100ms.live/v2
Usage
1. Creating a Room
Use the Hms facade to create a new room:
use TheAfolayan\HmsLaravel\Facades\Hms; $response = Hms::createRoom([ 'name' => 'My Room', 'template' => 'group_call', ]); echo $response['id'];
2. Generating a Room Code
Generate a room code for a specific room:
$roomId = 'room-id'; $response = Hms::generateRoomCode($roomId, [ 'role' => 'guest', 'expiry' => time() + (60 * 30) // 30 minutes ]); echo $response['code'];
3. Fetch Room Code Details
Retrieve details of a specific room code:
$code = 'room-code'; $details = Hms::getRoomCodeDetails($code); print_r($details);
4. List All Room Codes
List all room codes with optional parameters:
$codes = Hms::listRoomCodes(['limit' => 10]); print_r($codes);
5. Delete a Room Code
Delete a specific room code:
$code = 'room-code-to-delete'; $response = Hms::deleteRoomCode($code); echo $response['message'];
Testing
To test your package locally:
- Set up a Laravel project and add your package as a local repository.
- Use routes or controllers to test the package functionality.
- Run unit tests for the package:
./vendor/bin/phpunit
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a feature branch:
git checkout -b feature-name
. - Commit your changes:
git commit -m "Add new feature"
. - Push to the branch:
git push origin feature-name
. - Open a pull request.
License
This package is licensed under the MIT License.
Support
If you encounter any issues or have feature requests, please open an issue in the GitHub repository.