PHP Composer – 设置供应商目录

前端之家收集整理的这篇文章主要介绍了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基本模板一起使用.

原文链接:https://www.f2er.com/php/137581.html

猜你在找的PHP相关文章