dev-master
9999999-devSymfony2(3) bundle integration with 七牛 (Qiniu) CDN service
The Requires
by Anton Romanov
symfony2 bundle qiniu 七牛
Wallogit.com
2017 © Pedro Peláez
Symfony2(3) bundle integration with 七牛 (Qiniu) CDN service
This bundle aim is to help to work with 七牛 CDN service., (*1)
The work on bundle is in process, the documentation will be updated respectively., (*2)
Note: this bundle doesn't provide any 七牛 frontend related code., (*3)
Install: composer require nnmer/qiniu-bundle, (*4)
Add bundle AppKernel.php :, (*5)
... new Nnmer\QiniuBundle(), ...
nnmer_qiniu:
accessKey: xxxxxxx
secretKey: yyyyyyy
defaultBucket: a1
initiateAdapters:
- gaufrette
buckets: # is an array of the buckets, later each of them will be available as a service. Should be at least 1 provided
- a1
- b2
qiniu_processing_results:
resource: "@NnmerQiniuBundle/Controller/QiniuCallbackController.php"
type: annotation
prefix: /
- { path: ^/qiniu-callback-url, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/qiniu-persistence-notify-url, role: IS_AUTHENTICATED_ANONYMOUSLY }
- QiniuEvents::FILE_UPLOADED
- QiniuEvents::PERSISTENCE_RESULTS_RECEIVED, (*6)
the content of the event is the payload of the callback, so you can process you logic by listening to this events and manage the payload data, (*7)
If you want to have custom controller logic then do either:
- extend QiniuCallbackController class (this will give you existing 2 callbacks defined)
- implement QiniuCallbackControllerInterface interface (you will need to define the content for the controller's 2 callbacks methods), (*8)
In this case remember to repoint routing definition to your content, or remove it if you manage routing definitions yourself, (*9)
NOTE: bucket's name in services being renamed from original name:
all - arereplaces by _, (*10)
After container is built available next services:, (*11)
nnmer_qiniu.*_service , where * is each of the buckets, (*12)
and nnmer_qiniu.service which is alias to the service with defaultBucket, (*13)
if KnpGaufretteBundle is installed and nnmer_qiniu.initiateAdapters has gaufrette as array element then additional
next services will be generate:, (*14)
nnmer_qiniu.gaufrette_*_adapter where * is each of the buckets, (*15)
downloadUrl(url, service) - to build a download link, signed and with time expiration. service is the id of the needed service.
(in a controller the alias is $this->container->get('service id here')->getAuth()->privateDownloadUrl($url)), (*16)
Symfony2(3) bundle integration with 七牛 (Qiniu) CDN service
symfony2 bundle qiniu 七牛