如何在Composer-php中使所需的软件包成为全局软件包? [英] How do I make my required package global, without conflicts in composer-php?

查看:54
本文介绍了如何在Composer-php中使所需的软件包成为全局软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个软件包 sprout_services ,而我正在使用的其他3个软件包要求。一旦第一个运行的软件包需要它,它便在全局空间中打开。

Assume I have a package sprout_services that 3 other packages I'm using require. Once the first package to run has required it, then it is open in the global space.

在应用程序中的任何位置,我都可以执行 new SproutServices\ServiceLocator 。现在,一旦我有了第二个程序包初始化此 sprout_services ,就不可避免地会遇到 Class已经声明的问题,因为我想重新定义以前自动加载的类。

From anywhere in my application, I can do new SproutServices\ServiceLocator. Now, once I've had my second package initialize this sprout_services, I will inevitably be hit with the issue of Class has already been declared since I'm trying to re-define the same classes that were autoloaded before.

如何制作此 sprout_services code>程序包在全局状态下打开而不覆盖它并输入嘿,我是第一个在这里!的冲突?

How can I make this sprout_services package open in the global state without overriding it and entering conflicts of "hey, I was the first here!"?

推荐答案

我什么都没惊慌。

一旦解决依赖关系并因此被作曲家包括,它将进入全局名称空间并不能覆盖。 Composer知道并看到了这一点,并且不会尝试重新加载。

Once a dependency is resolved and therefore included by composer, it'll enter the global namespace and cannot be overwritten. Composer knows and sees this and it'll not attempt to re-load.

我不确定如果不同版本的类名相同会发生什么情况,我将进行更新当我找到更多答案时,就会得到这个答案。

I am not sure what happens if my class names are identical for different versions, I will update this answer as I find more.

这篇关于如何在Composer-php中使所需的软件包成为全局软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆