Download the PHP package jamal13647850/sms-api without Composer
On this page you can find all versions of the php package jamal13647850/sms-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jamal13647850/sms-api
More information about jamal13647850/sms-api
Files in jamal13647850/sms-api
Package sms-api
Short Description A unified PHP library for sending SMS messages through various Iranian SMS providers
License MIT
Informations about the package sms-api
SMS API Library
A comprehensive PHP library for sending SMS messages through various Iranian SMS providers.
Overview
This package provides a unified interface for sending SMS messages through different SMS gateways/providers in Iran. It follows SOLID principles with a clean architecture pattern that allows you to easily switch between different SMS service providers.
Features
- Unified Interface: Use the same code for all SMS providers
- Type Safety: Full PHP 8.2+ type declarations with strict types
- Error Handling: Comprehensive error handling with detailed messages
- Phone Number Validation: Automatic normalization and validation of Iranian phone numbers
- Pattern/Template Support: Send SMS using predefined patterns
- Credit Management: Check account balance across all providers
- Modern Architecture: Abstract base class to reduce code duplication
Supported Providers
| Provider | sendSMS | Pattern | Credit | Receive SMS | Status |
|---|---|---|---|---|---|
| FarazSMS | ✅ | ✅ | ✅ | ❌ | ✅ |
| SMS.ir | ✅ | ✅ | ✅ | ✅ | ✅ |
| FaraPayamak | ✅ | ✅ | ✅ | ✅ | ✅ |
| Payamito | ✅ | ✅ | ✅ | ✅ | ✅ |
| MedianaSMS | ✅ | ✅ | ✅ | ❌ | ❌ |
| Elanak (SOAP) | ✅ | ❌ | ✅ | ✅ | ✅ |
| Melipayamak | ✅ | ✅ | ✅ | ✅ | ✅ |
Requirements
- PHP 8.2 or higher
- curl extension enabled
- json extension enabled
- soap extension enabled (for Elanak provider)
Installation
Install the package via Composer:
Configuration
Copy the example environment file and configure your credentials:
Edit .env and fill in your actual API credentials. Never commit the .env file to version control!
Environment Variables
Required variables for Melipayamak:
Basic Usage
Response Format
All methods return a standardized response array:
Features
1. Send SMS to a Single Number
2. Send SMS to Multiple Numbers
3. Send SMS Using Predefined Patterns
Some providers support pattern-based messages (templates):
Real-world example with Melipayamak:
4. Check Account Credit
5. Get Message Delivery Status
6. Receive Incoming SMS
Provider-Specific Configuration
FarazSMS
SMS.ir
FaraPayamak / Payamito
Elanak
MedianaSMS
Melipayamak
⚠️ Important: Melipayamak uses ApiKey authentication, not your account password. Get the ApiKey from your panel's "توسعهدهندگان" (Developers) menu.
Melipayamak Pattern SMS Example
Switching Between Providers
One of the main advantages of this library is the ability to easily switch between different SMS providers:
Architecture
This library uses a clean architecture pattern:
- Gateway Interface: Defines the contract all providers must implement
- AbstractGateway: Provides common functionality (HTTP requests, phone validation, etc.)
- Provider Classes: Implement provider-specific logic
- SMS Facade: Provides a unified interface for consumers
Error Handling
The library provides detailed error information:
Common error codes:
0or positive: Success-1: General error-2: cURL error-3: JSON decode error-4: Invalid response format- HTTP status codes: HTTP errors
Testing
Manual Testing
Run the manual test suite (after configuring credentials in .env):
The test file includes examples for all providers.
Automated Unit Tests
We provide comprehensive PHPUnit tests for all providers:
Note: Integration tests require valid API credentials in your .env file. See .env.example for the required format.
Contributing
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create your feature branch:
git checkout -b feature/my-new-feature - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin feature/my-new-feature - Submit a pull request
Code Style
- Follow PSR-12 coding standards
- Use strict types:
declare(strict_types=1); - Add type hints for all parameters and return types
- Write clear documentation comments
Security
- Never hardcode credentials in your code
- Use environment variables or secure configuration management
- Keep your API keys private
- The
.envfile is already in.gitignore- don't remove it
For detailed security guidelines, see SECURITY.md.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Sayyed Jamal Ghasemi
📧 [email protected]
🔗 LinkedIn
All versions of sms-api with dependencies
ext-curl Version *
ext-json Version *
ext-soap Version *
vlucas/phpdotenv Version ^5.6