简体   繁体   English

CodeIgniter Composer的“ package.json”位置应位于应用程序或根文件夹中吗?

[英]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: 所以我有三个选择:

  1. Create a new package.json inside the application folder and install packages inside application . application文件夹中创建一个新的package.json ,并在application安装软件包。

  2. 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.

相关问题 package.json 和 composer.json 是一样的吗? - Is the same a package.json and a composer.json? 我可以用 composer.json 为我的 package 指定一个根文件夹(相对于项目根文件夹)吗? - May i specify a root folder (relative to project root folder) for my package with composer.json? 当 Google App Engine 项目的根文件夹在 composer.json 目录之外时,如何安装 composer 依赖项? - How to install composer dependencies when the root folder of the Google App Engine project is outside the composer.json directory? Codeigniter-切换根文件夹 - Codeigniter - switch root folder 如何从 codeigniter 应用程序中删除根文件夹名称 - How to remove the root folder name from codeigniter application 根 composer.json 需要 package dev-develop,找到 package 但它与约束不匹配 - Root composer.json requires package dev-develop, found package but it does not match the constraint Composer更新正在尝试删除根软件包 - Composer update is trying to remove the root package 将 codeIgniter 中的 Url 重定向到根文件夹 - Redirecting a Url in codeIgniter to a root folder Composer-供应商文件夹外部CodeIgniter中的自动加载类 - Composer - autoload classes in CodeIgniter outside vendor folder 如何使用composer获取根包路径 - How to get the root package path using composer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM