yohacodes/afro-msg-php
最新稳定版本:v0.0.1
Composer 安装命令:
composer require yohacodes/afro-msg-php
包简介
A modern, PSR-compliant PHP SDK for easily integrating with the Afromessage API. Includes support for verification, messaging, and more.
README 文档
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?
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-30