Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

通过composer引入后,类名重复 #4

Open
lxepoo opened this issue Sep 23, 2017 · 3 comments
Open

通过composer引入后,类名重复 #4

lxepoo opened this issue Sep 23, 2017 · 3 comments

Comments

@lxepoo
Copy link

lxepoo commented Sep 23, 2017

用composer autoload files来加载了,结果项目里有个Log类,和你们的Log类冲突了,报错Fatal error: Cannot declare class Log, because the name is already in use in E:\wwwroot\api-console\extra\aliyun-log\Aliyun\Log\sls.proto.php on line 129,这个有点致命了,因为你们的autoload方式所有类直接引入了全局名称空间,只要有任何一个地方和你们撞类名,你们这个SDK就不能用。

@alberthuang24
Copy link

有点惨...说明你的项目也没有命名空间嘛...

@alberthuang24
Copy link

bwt..阿里的sdk真的很水.建议自己写

@rbtyang
Copy link

rbtyang commented Dec 25, 2019

用composer autoload files来加载了,结果项目里有个Log类,和你们的Log类冲突了,报错Fatal error: Cannot declare class Log, because the name is already in use in E:\wwwroot\api-console\extra\aliyun-log\Aliyun\Log\sls.proto.php on line 129,这个有点致命了,因为你们的autoload方式所有类直接引入了全局名称空间,只要有任何一个地方和你们撞类名,你们这个SDK就不能用。

  • 修改 aliyun-log-php-sdk\Aliyun\Log\sls.proto.php 内的所有方法名,都加上前缀 Aliyun_,并全局搜索和修改相关引用【这一步是关键】
  • 注释掉 aliyun-log-php-sdk\Aliyun\Log\Client.php 内的 require_once realpath ( dirname ( __FILE__ ) . '/../../Log_Autoload.php' );
  • 将 阿里SDK 放到你的项目中任意位置,如 app/Libs/
  • 修改 你的项目根目录下的 composer.json,增加 classmap 配置项 app/Libs/aliyun-log-php-sdk/Aliyun(根据上一步放的位置决定)
  • 执行 composer dumpautoload, Finish~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants