- php version 8.1
- composer installed
- docker
- Curl PHP Extension
- JSON PHP Extension
- Mbstring PHP Extension
- XML PHP Extension
- Mongodb PHP Extension (important)
- Redis PHP Extension
git clone https://github.com/hamidroohani/SMS-Gateway.git
cd SMS-Gateway && cp .env.example .env
Install other services with docker compose
cd docker && sudo docker-compose up -d
Install composer
cd .. && composer install
connect to docker mongodb
sudo docker exec -it [hash-code-from-mongo] bash
mongo -u root
use sms-gateway
db.createUser(
{
user: "user-sms-gateway",
pwd: "97v4MUt8s25G1",
roles:
[
{
role:"readWrite",
db:"sms-gateway"
},
]
});
Also create another database for test
use test-sms-gateway
db.createUser(
{
user: "user-sms-gateway",
pwd: "97v4MUt8s25G1",
roles:
[
{
role:"readWrite",
db:"test-sms-gateway"
},
]
});
exit from docker container and run:
php artisan key:generate
php artisan migrate
php artisan test
If you're faced with any errors in test, try to find the problems, most of all it happens of connection between services
nano database/seeders/ProviderSeeder.php
After that run the seeder
php artisan db:seed
cd /path-to-your-project && php artisan send:sms
php artisan serve
This is an example of a POST
request API for send a message.
POST /api/messages/send
Accept: application/json
{
"body": "salam",
"receiver_mobile": "09375775947"
}
{
"status": true,
"data": {
"track_id": "62aff1e9424f29b97e0a61a3"
}
}
You can use the track id for next Api.
This is an example of a POST
request API for track a message that sent before.
POST /api/messages/track/{track_id}
Accept: application/json
{
"status": true,
"data": {
"status": "pending"
}
}
Also, you can use the postman_file
in the root.
cd /path-to-your-project && php artisan amqp:consume
Note: Between those two command for send sms, use just one of them