lokielse / laravel-mns
Aliyun MNS Queue Driver For Laravel
Installs: 14 828
Dependents: 0
Suggesters: 0
Security: 0
Stars: 26
Watchers: 2
Forks: 5
Open Issues: 2
pkg:composer/lokielse/laravel-mns
Requires
- php: ~5.5|~7.0
- laravel/framework: ~5.1
- lokielse/aliyun-open-api-mns: ^1.0.2
Requires (Dev)
- phpunit/phpunit: ~4.0||~5.0
- scrutinizer/ocular: ~1.1
- squizlabs/php_codesniffer: ~2.3
README
Install
Via Composer
$ composer require lokielse/laravel-mns
Config
Add following service providers into your providers array in config/app.php
Lokielse\LaravelMNS\LaravelMNSServiceProvider::class
Edit your config/queue.php, add mns connection
'mns' => [ 'driver' => 'mns', 'key' => env('QUEUE_MNS_ACCESS_KEY'), 'secret' => env('QUEUE_MNS_SECRET_KEY'), 'endpoint' => env('QUEUE_MNS_ENDPOINT'), 'queue' => env('QUEUE_NAME'), 'wait_seconds' => 30, ]
About wait_seconds
Edit your .env file
QUEUE_DRIVER=mns QUEUE_NAME=foobar-local QUEUE_MNS_ACCESS_KEY=your_acccess_key QUEUE_MNS_SECRET_KEY=your_secret_key QUEUE_MNS_ENDPOINT=http://12345678910.mns.cn-hangzhou.aliyuncs.com/
You should update QUEUE_MNS_ENDPOINT to internal endpoint in production mode
Usage
First create a queue and get queue endpoint at Aliyun MNS Console
Then update MNS_ENDPOINT in .env
Push a test message to queue
Queue::push(function($job){ /** * Your statments go here */ $job->delete(); });
Create queue listener, run command in terminal
$ php artisan queue:listen
Commands
Flush MNS messages on Aliyun
$ php artisan queue:mns:flush
Security
Create RAM access control at Aliyun RAM Console
-
Create a custom policy such as
AliyunMNSFullAccessFoobar{ "Version": "1", "Statement": [ { "Action": "mns:*", "Resource": [ "acs:mns:*:*:*/foobar-local", "acs:mns:*:*:*/foobar-sandbox", "acs:mns:*:*:*/foobar-production" ], "Effect": "Allow" } ] } -
Create a user for you app such as
foobar -
Assign the policy
AliyunMNSFullAccessFoobarto the userfoobar -
Create and get the
AccessKeyIdandAccessKeySecretfor userfoorbar -
update
QUEUE_MNS_ACCESS_KEYandQUEUE_MNS_ACCESS_SECRETin.env
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Credits
License
The MIT License (MIT). Please see License File for more information.