Article From:

In fact, it’s not just the Yii framework that can be used, because it’s just a class library that can be used in any framework.

preparation in advance

1.Register with Qiniu at

2.Create a space (remember the name of the storage space and the storage area)

3.Create the secret key


Step one:

Add “crazyfd/yii2-qiniu” to the require attribute in composer.json: “dev-master”

The second step:

 Perform composer update in the root directory

The third step:

    public function actionTest()
        $ak = 'Own ak';
        $sk = 'Own sk';
        $domain = 'My address';//View it at page
        $qiniu = new \crazyfd\qiniu\Qiniu($ak, $sk,$domain, 'Create the name of the space','the region';//East China (default), North China, South China, North America
        $key = time();
        $url = $qiniu->getLink($key);//Picture URL
        echo $url;

The test can be tested with postman, and the parameter name is file.

The annotations are very clear. If you don’t understand the message or the menu on the left, add me QQ.

Leave a Reply

Your email address will not be published. Required fields are marked *