[英]CodeIgniter Composer “package.json” locations shluld be in application or root folder?
I working with code igniter v3.x and I would like to add some composer packages. 我正在使用代码点火器v3.x,并且我想添加一些作曲家软件包。
looking at application/config/config.php
file, it says that will load packages inside application folder 查看application/config/config.php
文件,它表示将在应用程序文件夹内加载软件包
| package auto-loader script in application/vendor/autoload.php.
However in the codeigniter package it already has a package.json
that installs packages on root folder. 但是,在codeigniter软件包中,它已经具有package.json
,可以在根文件夹中安装软件包。
I suspect that the package.json
on the root must hold only information about CodeIgniter it self. 我怀疑根目录下的package.json
本身只能包含有关CodeIgniter的信息。 But I'm not sure. 但是我不确定。
So I have three options: 所以我有三个选择:
Create a new package.json
inside the application
folder and install packages inside application
. 在application
文件夹中创建一个新的package.json
,并在application
安装软件包。
Modify the package.json
on the root folder by adding new package and change autoload.php
location 通过添加新软件包并更改autoload.php
位置,在根文件夹上修改package.json
What is expected from a CodeIgniter Application? CodeIgniter应用程序会有什么期望?
Well, if you take a look at the Codeigniter Documentation you can see there is a Configuration setting called composer_autoload
. 好吧,如果您看一下Codeigniter文档,就会发现有一个名为composer_autoload
的配置设置。 This information can be found here . 这些信息可以在这里找到。
If you set this true
, Codeigniter tries to load Composer's autoload.php in the APPLICATION.'vendor'
folder. 如果设置为true
,则Codeigniter尝试将COMPOSER的autoload.php加载到APPLICATION.'vendor'
文件夹中。 If you take a closer look at the Codeigniter.php file, you'll see that you can define a directory for this setting too. 如果仔细查看Codeigniter.php文件,您会发现也可以为此设置定义目录。
So in your case you don't have to change the package.json
in the root folder because you need one in the application folder, in case you set composer_autoload
to true
, which i would recommend. 因此,在您的情况下,无需更改根文件夹中的package.json
,因为在将composer_autoload
设置为true
情况下,您需要在应用程序文件夹中更改package.json
,我建议这样做。
By the way if you try to install a package via composer in your application directory, composer asks you if you want to use the one it found on the root folder - just decline that and press n
. 顺便说一句,如果您尝试通过composer在应用程序目录中安装软件包,则composer询问您是否要使用在根文件夹中找到的软件包-拒绝并按n
。
As you can see in the picture below (i just tried to install the mpdf package). 如您在下面的图片中看到的(我只是尝试安装mpdf软件包)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.