composer psr4自动加载,引入适用第三方开源项目

[root@izbp18dv3a3metugyd02qxz syhuo.net]# vim composer.json
{
    "require" : {
        "elasticsearch/elasticsearch": "~2.0",
         "qcloud/cos-sdk-v5": ">=1.0",
        "aliyuncs/oss-sdk-php": "^2.3",
        "aws/aws-sdk-php": "2.8.24"
    },
    "autoload" : {
        "psr-4" : {
            "General\\" : "./General/",
            "Role\\" : "./General/Role/",
            "MyException\\" : "./General/Exception/"
        }
    },
    "repositories": {
        "packagist": {
            "type": "composer",
            "url": "https://mirrors.aliyun.com/composer/"
        }
    }
}

[root@izbp18dv3a3metugyd02qxz vendor]# ll
total 60
drwxrwxrwx 14 root root 4096 Jan 15 16:06 ./
drwxrwxrwx 19 root root 4096 Apr 23 11:49 ../
drwxrwxrwx  3 root root 4096 Dec  6 11:25 aliyuncs/
-rwxrwxrwx  1 root root  178 Jan 15 16:06 autoload.php*
drwxrwxrwx  3 root root 4096 Jan 15 16:05 aws/
drwxrwxrwx  2 root root 4096 Apr  8  2018 bin/
drwxrwxrwx  2 root root 4096 Jan 15 16:05 composer/
drwxrwxrwx  3 root root 4096 Jan 15 16:05 elasticsearch/
drwxrwxrwx  3 root root 4096 Apr  8  2018 guzzle/
drwxrwxrwx  9 root root 4096 Jan 15 16:05 guzzlehttp/
drwxrwxrwx  4 root root 4096 Jan 15 16:05 psr/
drwxrwxrwx  3 root root 4096 Jan 15 16:05 qcloud/
drwxrwxrwx  3 root root 4096 Jan 15 16:05 ralouphie/
drwxrwxrwx  3 root root 4096 Jan 15 16:05 react/
drwxrwxrwx  3 root root 4096 Jan 15 16:05 symfony/


use General\Constant\DeviceStatus;
use Role\Constant\RoleGroup;
use Role\Constant\RoleInfo;
use Role\RoleDataBuilder;


[root@izbp18dv3a3metugyd02qxz OSS]# ll
total 128
drwxrwxrwx 6 root root   4096 Jan  8 09:37 ./
drwxrwxrwx 3 root root   4096 Dec  6 09:53 ../
drwxrwxrwx 2 root root   4096 Dec  6 09:53 Core/
drwxrwxrwx 2 root root   4096 Jan  8 09:38 Http/
drwxrwxrwx 2 root root   4096 Dec  6 09:53 Model/
-rwxrwxrwx 1 root root 102469 Dec  6 09:53 OssClient.php*
drwxrwxrwx 2 root root   4096 Dec  6 09:53 Result/
[root@izbp18dv3a3metugyd02qxz OSS]# pwd
/data/www/syhuo.net/vendor/aliyuncs/oss-sdk-php/src/OSS


[root@izbp18dv3a3metugyd02qxz syhuo.net]# vim General/Classes/QcloudApi.php
<?php
namespace General\Classes;

/**
 * Qcloud 接口类
 * @author 刘超 <249757247@qq.com> 2019-12-05
 */
class QcloudApi
{
    protected $config = [
        'accessyeyid'     => 'LTAI4Fm1GK7WAwgdkHgREBWT',
        'accesskeysecret'  => 'UxTwM4II0aWSFPhAPepcyDSM3iO9YJ',
        'endpoint' => 'http://oss-cn-hangzhou-internal.aliyuncs.com',
        'bucket'    => 'syhuo-20200108'
        ];
    protected $ossClient = null;
    /**
     * [__construct description]
     * @author 刘超 <249757247@qq.com> 2019-12-05
     */
    public function __construct()
    {
        $ossClient = new \OSS\OssClient(
                $this->config['accessyeyid'],
                $this->config['accesskeysecret'],
                $this->config['endpoint']
                );
        $this->ossClient = $ossClient;
    }



 

 

上一篇:CV 第九课 CNN框架 全连接层


下一篇:【Java Web开发指南】Java插入中文到数据库中文变成问号解决