PHP Composer – 设置供应商目录

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了PHP Composer – 设置供应商目录脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我在配置Yii2应用程序的供应商路径时遇到问题.我在从Yii2基本应用程序模板中获取的composer.json文件添加了几行.我想要做的就是更改供应商资产的位置.

以下是我对文件所做的更改,但是我收到此错误

The file or directory to be published does not exist: /path/to/app/vendor/bower/jquery/dist

但我期待将该特定资产发布到:

/path/to/vendors/bower/jquery/dist

无论我做什么,我仍然会收到错误消息.我怀疑这是一个Yii2问题而不是作曲家问题,但我不确定.有人有任何想法吗?提前致谢.

文件

的index.PHP

// comment out the following two lines when deployed to PRoduction
defined('YII_DEBUG') or define('YII_DEBUG',true);
defined('YII_env') or define('YII_ENV','dev');

require('/path/to/vendors/autoload.PHP');
require('/path/to/vendors/yiisoft/yii2/Yii.PHP');

$config = require(__DIR__ . '/../config/web.PHP');

(new yii\web\Application($config))->run();

composer.json

{
    "name": "yiisoft/yii2-app-basic","description": "Yii 2 Basic Project Template","keywords": ["yii2","framework","basic","project template"],"homepage": "http://www.yiiframework.COM/","tyPE": "project","license": "BSD-3-Clause","support": {
        ...
    },"minimum-stabilITy": "dev","config": {
        "process-timeout": 1800,"vendor-dir": "/path/to/vendors"
    },"require": {
        "fxp/composer-asset-plugin": "~1.0",...
    },"extra": {
        "asset-installer-paths": {
            "npm-asset-library": "../../includes/vendors/npm","bower-asset-library": "../../includes/vendors/bower"
        }
    }
}
事实证明,有一个简单解决方案:如果您想更改供应商资产的位置,那么您必须遵循以下简单步骤:

>在composer.json文件中包含composer-asset-plugin

"require": {
    "fxp/composer-asset-plugin": "*"
}

>在额外配置中包含composer-asset-plugin指令.在您的composer.json文件中:

"extra": {
"asset-installer-paths": {
        "npm-asset-library": "../../path/to/vendors/npm","bower-asset-library": "../../path/to/vendors/bower"
    }
}

>将供应商位置添加到composer.json文件的config部分:

"config": {
    "vendor-dir": "../../path/to/vendors"
}

>更新web / index.PHP以指向新的供应商位置:

require(__DIR__ . '/../../../path/to/vendors/autoload.PHP');
require(__DIR__ . '/../../../path/to/vendors/yiisoft/yii2/Yii.PHP');

>在config / web.PHP中包含vendorPath定义:

'vendorPath' => '../../../path/to/vendors',

应该与香草Yii2基本模板一起使用.

脚本宝典总结

以上是脚本宝典为你收集整理的PHP Composer – 设置供应商目录全部内容,希望文章能够帮你解决PHP Composer – 设置供应商目录所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。