问题
I working with code igniter v3.x and I would like to add some composer packages.
looking at application/config/config.php
file, it says that will load packages inside application folder
| 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.
I suspect that the package.json
on the root must hold only information about CodeIgniter it self. But I'm not sure.
So I have three options:
Create a new
package.json
inside theapplication
folder and install packages insideapplication
.Modify the
package.json
on the root folder by adding new package and changeautoload.php
location
What is expected from a CodeIgniter Application?
回答1:
Well, if you take a look at the Codeigniter Documentation you can see there is a Configuration setting called 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. If you take a closer look at the Codeigniter.php file, you'll see that you can define a directory for this setting too.
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.
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
.
As you can see in the picture below (i just tried to install the mpdf package).
来源:https://stackoverflow.com/questions/52574192/codeigniter-composer-package-json-locations-shluld-be-in-application-or-root-f