加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP Composer – 设置供应商目录

发布时间:2020-12-13 13:29:27 所属栏目:PHP教程 来源:网络整理
导读:我在配置Yii2应用程序的供应商路径时遇到问题.我在从Yii2基本应用程序模板中获取的composer.json文件中添加了几行.我想要做的就是更改供应商资产的位置. 以下是我对文件所做的更改,但是我收到此错误: The file or directory to be published does not exist
我在配置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 yiiwebApplication($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基本模板一起使用.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读