yohacodes/afro-msg-php

A modern, PSR-compliant PHP SDK for easily integrating with the Afromessage API. Includes support for verification, messaging, and more.

v0.0.1 2025-05-30 13:44 UTC

This package is auto-updated.

Last update: 2025-06-08 05:55:39 UTC


README

Latest Version Build Status

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!

  1. Fork the repo
  2. Run composer install
  3. Create your feature branch (git checkout -b feature/my-feature)
  4. Commit your changes
  5. Push to the branch
  6. 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?