yohacodes / afro-msg-php
A modern, PSR-compliant PHP SDK for easily integrating with the Afromessage API. Includes support for verification, messaging, and more.
Requires
- php: ^7.4 || ^8.0
- guzzlehttp/guzzle: ^7.9
- symfony/var-dumper: ^7.3
- vlucas/phpdotenv: ^5.6
Requires (Dev)
- phpunit/phpunit: ^12.1
README
AfroMsg is a modern, extensible PHP SDK for integrating with the Afromessage API. It supports token-based authentication, code verification, message sending, and is fully PSR-compliant. Ideal for Laravel and any PHP-based backend.
๐ Features
- โ Clean and simple API for SMS verification and messaging
- โ PSR-4 & PSR-12 compliant structure
- โ Laravel-ready (via optional ServiceProvider)
- โ Extensible via interfaces (use Guzzle, Curl, or any HTTP client)
- โ Fully tested with PHPUnit
- โ IDE-friendly with stubs and PHPDocs
๐ฆ Installation
Install the SDK using Composer:
composer require yohacodes/afro-msg-php
โ๏ธ Configuration
Create a .env
file or define your token manually:
AFROMESSAGE_API_TOKEN=your_api_token
Alternatively, configure directly in code:
$client = new \AfroMsg\Http\GuzzleAfromessageClient('your_api_token');
โจ Quick Start
๐ Verify Code
use AfroMsg\Http\GuzzleAfromessageClient; $client = new GuzzleAfromessageClient('your_api_token'); $response = $client->verifyCode('+251912345678', '123456'); if ($response['success']) { echo "Code verified!"; } else { echo "Verification failed."; }
๐งฑ Architecture
AfroMsg\
โโโ Contracts\ # Interfaces for HTTP clients
โโโ Http\ # Guzzle implementation (default)
โโโ Responses\ # Response wrappers
โโโ Exceptions\ # Custom exception classes
โโโ Support\ # Helper utilities
โโโ AfroMsg.php # Facade for simplified usage
โโโ stubs\ # IDE stubs and config templates
๐งช Testing
Run all unit and feature tests using:
vendor/bin/phpunit
We recommend using Mockery
and Guzzle MockHandler
for mocking API calls.
๐งฉ Extending
Create a custom client by implementing the interface:
namespace AfroMsg\Contracts; interface AfromessageClientInterface { public function verifyCode(string $to, string $code): array; }
You can then inject or bind your implementation as needed.
๐ฏ Laravel Integration (Optional)
For Laravel users, a service provider and config file can be published:
php artisan vendor:publish --provider="AfroMsg\AfromessageServiceProvider"
use AfroMsg\Facades\AfroMsg; AfroMsg::verifyCode('0912345678', '4567');
๐ง Roadmap
- Basic verify functionality
- SMS sending
- Delivery reports
- Balance check
- Notifications and webhooks
- Laravel package auto-discovery
๐ค Contributing
Contributions are welcome!
- Fork the repo
- Run
composer install
- Create your feature branch (
git checkout -b feature/my-feature
) - Commit your changes
- Push to the branch
- Create a new Pull Request
๐ก License
This package is open-sourced software licensed under the MIT license.
๐ Contact & Support
For questions or support, please open an issue or email support@yourdomain.com
.
Crafted with โค๏ธ by Yohannes Z. (https://github.com/yohacode)
---
### โ
Next Steps
If you'd like, I can:
- Generate this as a full GitHub-ready package
- Scaffold the full project structure as a `.zip`
- Add CI workflow (`.github/workflows/tests.yml`)
- Create Packagist metadata
Would you like the full structure generated?