hivelink/laravel
Laravel SDK for Hivelink SMS and Inquiry API. Install via Composer, register the service provider/facade, publish config, and set your API key. Send SMS with Hivelink::SendSimple and handle API/HTTP exceptions.
Installation:
composer require hivelink/laravel
Register Service Provider in config/app.php:
'providers' => [
// ...
Hivelink\Laravel\ServiceProvider::class,
],
Add Facade Alias in config/app.php:
'aliases' => [
// ...
'Hivelink' => Hivelink\Laravel\Facade::class,
],
Publish Config (if needed):
php artisan vendor:publish --provider="Hivelink\Laravel\ServiceProvider"
This generates config/hivelink.php.
Configure API Key in .env:
HIVE_LINK_API_KEY=your_api_key_here
use Hivelink\Facades\Hivelink;
Hivelink::sms()
->to('2348012345678')
->message('Hello from Laravel!')
->send();
Hivelink::sms()
->to('2348012345678')
->message('Your OTP is 12345')
->send();
Hivelink::sms()
->to('2348012345678')
->message('Scheduled message')
->schedule(Carbon::now()->addMinutes(10))
->send();
$balance = Hivelink::inquiry()->balance();
$usage = Hivelink::inquiry()->usage();
HIVE_LINK_LOG_ENABLED=true in .env):
// Logs to `hivelink_logs` table by default
try {
Hivelink::sms()->to('2348012345678')->message('Test')->send();
} catch (\Hivelink\Exceptions\HivelinkException $e) {
Log::error('Hivelink Error: ' . $e->getMessage());
}
HIVE_LINK_QUEUE_CONNECTION in .env (e.g., database, redis).send() to dispatch jobs asynchronously.use Hivelink\Facades\Hivelink;
Route::middleware(['throttle:10,1'])->group(function () {
Route::post('/send-sms', function () {
Hivelink::sms()->to('2348012345678')->message('Test')->send();
});
});
config(['hivelink.api_key' => getApiKeyFromSecureSource()]);
Hivelink::shouldReceive('sms')
->once()
->andReturnSelf()
->shouldReceive('send')
->once();
API Key Exposure:
.env for production. Use environment variables or secret managers.HIVE_LINK_API_KEY exists in config/hivelink.php:
'api_key' => env('HIVE_LINK_API_KEY') ?: throw new \RuntimeException('API key not set'),
Queue Failures:
HIVE_LINK_QUEUE_CONNECTION is properly configured. Monitor failed jobs in failed_jobs table.Rate Limits:
use Hivelink\Facades\Hivelink;
$attempts = 0;
$maxAttempts = 3;
do {
try {
Hivelink::sms()->to('2348012345678')->message('Test')->send();
break;
} catch (\Hivelink\Exceptions\RateLimitException $e) {
$attempts++;
sleep(2 ** $attempts);
}
} while ($attempts < $maxAttempts);
Logging Overhead:
HIVE_LINK_LOG_ENABLED=false).Enable Debug Mode:
HIVE_LINK_DEBUG=true
storage/logs/hivelink.log.Check HTTP Status Codes:
try-catch to inspect HivelinkException for HTTP errors (e.g., 401 Unauthorized).Validate Phone Numbers:
$request->validate(['phone' => 'required|string|hivelink_phone']);
Validator::extend('hivelink_phone', function ($attribute, $value) {
return preg_match('/^\+\d{10,15}$/', $value);
});
Custom Responses:
class CustomHivelink extends \Hivelink\Laravel\Facade {
public static function bulkSend(array $messages) {
// Custom logic
}
}
Webhook Integration:
Route::post('/hivelink-webhook', function (Request $request) {
$payload = $request->json()->all();
// Process delivery status, etc.
});
Template Management:
$template = DB::table('sms_templates')->where('key', 'welcome')->first();
Hivelink::sms()->to('2348012345678')->message($template->content)->send();
Fallback Mechanisms:
try {
Hivelink::sms()->to('2348012345678')->message('Fallback')->send();
} catch (\Exception $e) {
// Fallback to Twilio, etc.
}
How can I help you explore Laravel packages today?