Download the PHP package fardadev/kavenegar-for-laravel without Composer
On this page you can find all versions of the php package fardadev/kavenegar-for-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fardadev/kavenegar-for-laravel
More information about fardadev/kavenegar-for-laravel
Files in fardadev/kavenegar-for-laravel
Package kavenegar-for-laravel
Short Description Modern Laravel 11+ package for Kavenegar SMS API integration with full type safety and comprehensive testing
License MIT
Homepage https://github.com/FardaDev/kavenegar-for-laravel
Informations about the package kavenegar-for-laravel
Kavenegar Laravel Package
Modern Laravel 11+ package for Kavenegar SMS API integration with full type safety, comprehensive testing, and Laravel best practices.
Features
- ✅ Laravel 11+ Compatible - Built for modern Laravel with PHP 8.3+
- ✅ Full Type Safety - Strongly typed with readonly DTOs and return types
- ✅ Auto-Discovery - Automatic service provider and facade registration
- ✅ Comprehensive API Coverage - All Kavenegar endpoints supported
- ✅ Exception Handling - Typed exceptions for different error scenarios
- ✅ Helper Methods - Convenient helpers for common use cases
- ✅ Environment Aware - Skip SMS in development/testing environments
- ✅ Fully Tested - Comprehensive test coverage with Pest
- ✅ Well Documented - Complete API documentation and examples
Requirements
- PHP 8.3 or higher
- Laravel 11.0 or 12.0
- Kavenegar API Key (Get one here)
Installation
Install the package via Composer:
The package will automatically register itself thanks to Laravel's auto-discovery feature.
Publish Configuration
Publish the configuration file:
This will create a config/kavenegar.php file in your application.
Environment Variables
Add your Kavenegar credentials to your .env file:
Configuration
The config/kavenegar.php file contains all package configuration options:
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
api_key |
string | - | Your Kavenegar API key (required) |
sender |
string|null | null | Default sender line number |
timeout |
int | 30 | HTTP request timeout in seconds |
skip_in_development |
bool | true | Skip SMS in local/dev environments |
test_phone_numbers |
array | [] | Phone numbers treated as test numbers |
templates |
array | [] | Template names for verification codes |
Usage
Basic SMS Sending
Using Facade
Using Dependency Injection
Bulk SMS Sending
Send different messages to different recipients from different senders:
Verification Codes
Using verifyLookup
Using Helper Methods
The package includes a KavenegarHelper class with convenient methods for common verification scenarios. This helper automatically handles development environment skipping and token normalization.
Note: The KavenegarHelper is a convenience implementation for common use cases. You can create your own custom helper class by injecting KavenegarClient and implementing logic specific to your application's needs.
Checking Message Status
Message History and Selection
Cancelling Messages
Voice Calls (TTS)
Account Information
Advanced Features
Creating Custom Helpers
While the package includes KavenegarHelper for common scenarios, you can create your own custom helper tailored to your application's specific needs:
Then use it in your application:
Exception Handling
The package throws specific exceptions for different error scenarios:
Environment-Based Testing
The package can skip SMS sending in development/testing environments:
Privacy Features
Hide receptor numbers in logs and console:
Duplicate Prevention
Use local IDs to prevent duplicate sends:
Message Tagging
Organize messages with tags:
Custom Sending Policies
Use custom sending flows (if configured in panel):
Data Transfer Objects (DTOs)
All responses are strongly-typed readonly objects:
Error Codes
Common error codes you might encounter:
| Code | Description | Exception Type |
|---|---|---|
| 200 | Success | - |
| 400 | Incomplete parameters | ValidationException |
| 401 | Invalid API key | ApiException |
| 402 | Operation failed | ApiException |
| 407 | Access denied (IP restriction) | ApiException |
| 411 | Invalid receptor number | ValidationException |
| 412 | Invalid sender number | ValidationException |
| 413 | Message too long or empty | ValidationException |
| 414 | Too many records | ValidationException |
| 418 | Insufficient credit | ApiException |
| 419 | Array length mismatch | ValidationException |
See docs/error-codes.md for complete error code reference.
API Documentation
For detailed API documentation, see:
- API Endpoints - Complete endpoint reference
- Error Codes - Error code reference and troubleshooting
- Migration Guide - Migrating from old package
Testing
Static Analysis
Code Formatting
Changelog
Please see CHANGELOG for recent changes.
Contributing
Contributions are welcome! Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
Credits
- FardaDev
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
Support
All versions of kavenegar-for-laravel with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0