在yii2基本应用程序的供应商文件夹中找不到Bower文件夹


Bower folder is not found in vendor folder in yii2 basic application

我下载了一个基本的yii2应用程序。然后推到git。但后来在其他电脑上,我使用composer安装了所有的依赖项。但我现在没有bower文件夹,所以出现错误:

The file or directory to be published does not exist: C:'xampp'htdocs'jumpbyte-site'vendor'bower/jquery/dist'

我的composer.json文件具有以下必需依赖项:

"require": {
        "php": ">=5.4.0",
        "yiisoft/yii2": "*",
        "yiisoft/yii2-bootstrap": "*",
        "yiisoft/yii2-swiftmailer": "*",
        "himiklab/yii2-sitemap-module": "*"
    },

要通过Composer管理bower和npm包依赖关系,您需要(全局)安装fxp/Composer资产插件:

composer global require "fxp/composer-asset-plugin:~1.1.1"
composer install

阅读更多:http://www.yiiframework.com/doc-2.0/guide-start-installation.html#installing-通过composer

首先下载默认依赖项

composer global require "fxp/composer-asset-plugin:~1.0.3"

然后运行

composer install

然后重新加载您的网站。

Goto/vendor/yiisoft/yii2/base/Application.php。

转到456线。

更改

Yii::setAlias('@bower',$this->_vendorPath.DIRECTORY_SEPARATOR.'bower');

Yii::setAlias('@bower',$this->_vendorPath.DIRECTORY_SEPARATOR.'bower'.DIRECTORY_SEPARATOR.'bower-asset');

这可能会在以后破坏一些东西,但这比试图根除composer问题要快得多。我也试过了,但没有成功。我只是决定按它的要求给它。

如果有人知道为什么这种变通方法不好,请大声说出来。

Goto/vendor/yiisoft/yii2/base/Application.php。

    public function setVendorPath($path)
{
    $this->_vendorPath = Yii::getAlias($path);
    Yii::setAlias('@vendor', $this->_vendorPath);
    Yii::setAlias('@bower', $this->_vendorPath . DIRECTORY_SEPARATOR . 'bower-asset'); //it was just 'bower'
    Yii::setAlias('@npm', $this->_vendorPath . DIRECTORY_SEPARATOR . 'npm');
}

(用于新安装)在Windows上。

  1. 删除windows上的composer并重新安装。之后
  2. composer global require "fxp/composer-asset-plugin:~1.1.1"
  3. composer create-project --prefer-dist yiisoft/yii2-app-advanced yii-application

(用于更新):删除目录上的内容:

  1. 供应商删除文件
  2. composer.lock
  3. composer install

这都是

在我的例子中,我有旧版本的composer资产插件,但它不能正常工作。只有更新对我有帮助。所以更新到composer资产插件的最后一个版本:

composer global require "fxp/composer-asset-plugin:^1.2.0"

看看^1.2.0。这很重要。

然后执行以下命令:

rm -rf vendor/*
rm composer.lock
composer install