2017 © Pedro Peláez
 

library qiniu-bundle

Symfony2(3) bundle integration with 七牛 (Qiniu) CDN service

image

nnmer/qiniu-bundle

Symfony2(3) bundle integration with 七牛 (Qiniu) CDN service

  • Monday, September 4, 2017
  • by nnmer
  • Repository
  • 1 Watchers
  • 3 Stars
  • 61 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 11 % Grown

The README.md

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)

Installation & Configuration

Note: this bundle doesn't provide any 七牛 frontend related code., (*3)

  1. Install: composer require nnmer/qiniu-bundle, (*4)

  2. Add bundle AppKernel.php :, (*5)

 ...
 new Nnmer\QiniuBundle(),
 ...
  1. Add bundle configuration at config.yml
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
  1. Add to you routing
qiniu_processing_results:
    resource: "@NnmerQiniuBundle/Controller/QiniuCallbackController.php"
    type:     annotation
    prefix:   /
  1. if you are behind symfony's firewall, then add to your security.yml access_control section:
- { path: ^/qiniu-callback-url, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/qiniu-persistence-notify-url, role: IS_AUTHENTICATED_ANONYMOUSLY }
  1. Done. From this point once you will receive a callback from Qiniu the 2 events can be raised, depends on the callback:

- 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)

Overwriting controller

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)

Available services

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)

Twig helpers

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)

The Versions

04/09 2017

dev-master

9999999-dev

Symfony2(3) bundle integration with 七牛 (Qiniu) CDN service

  Sources   Download

The Requires

 

by Anton Romanov

symfony2 bundle qiniu 七牛