Yii2 与 composer 和 fxp/composer-asset-plugin

Posted

技术标签:

【中文标题】Yii2 与 composer 和 fxp/composer-asset-plugin【英文标题】:Yii2 with composer and fxp/composer-asset-plugin 【发布时间】:2016-12-05 13:00:17 【问题描述】:

我正在开发一个使用 Yii2 php 框架的项目。 Yii2 使用 composerfxp/composer-asset-plugin 来处理项目依赖关系。

问题是当新的开发人员来到项目并运行时

git clone <project-repo>
composer install

或者另一个开发者想用composer require &lt;package-name&gt; 安装一个新的扩展经常(经常)出现问题和composer(或者可能是asset plugin,我在上面提到过)显示另一个不清楚的错误消息(可能只对我来说)。开发人员会花费大量时间来查找该错误的含义以及如何处理它。

今天我在 Windows 机器上克隆了项目,安装了最新的 composerasset plugin 版本,运行composer install,大约等待 20 分钟后,得到了这个:

在我的 Linux 系统上,相同的依赖项已安装且没有错误。

问题№1 这个错误是什么意思,我该如何解决?

问题№2vendor/ 目录添加到版本控制中是不是很糟糕? (我读过https://getcomposer.org/doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md)

问题№3 也许我做错了什么,或者有一个我不知道的秘密,它允许在 Yii2 中管理依赖关系而不会浪费这么大的时间。

非常感谢。

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": 
        "issues": "https://github.com/yiisoft/yii2/issues?state=open",
        "forum": "http://www.yiiframework.com/forum/",
        "wiki": "http://www.yiiframework.com/wiki/",
        "irc": "irc://irc.freenode.net/yii",
        "source": "https://github.com/yiisoft/yii2"
    ,
    "repositories": [
        
            "type": "git",
            "url":  "https://github.com/ZeroVision/swiftmailer.git"
        
    ],
    "minimum-stability": "dev",
    "require": 
        "php": ">=5.4.0",
        "giggsey/libphonenumber-for-php": "~7.0",
        "yiisoft/yii2": "2.0.7",
        "swiftmailer/swiftmailer": "dev-fixStreamBufferTransport",
        "yiisoft/yii2-bootstrap": ">=2.0.3",
        "yiisoft/yii2-swiftmailer": "*",
        "yiisoft/yii2-authclient": "^2.0@dev",
        "2amigos/yii2-date-picker-widget": "~1.0",
        "kartik-v/yii2-widget-timepicker": "*",
        "kartik-v/yii2-widget-rating": "*",
        "2amigos/yii2-gallery-widget": "~1.0",
        "2amigos/yii2-ckeditor-widget": "~1.0",
        "uran1980/yii2-scroll-to-top": "dev-master",
        "yii-cms/yii2-robokassa": "^1.1",
        "onokumus/metismenu": "v2.4.2",
        "rmrevin/yii2-fontawesome": "*",
        "dektrium/yii2-user": "*",
        "p2made/yii2-sb-admin-theme": "1.1.2",
        "p2made/yii2-p2y2-things": "*",
        "p2made/yii2-asset-collection": "*",
        "demi/image": "~1.0",
        "demi/cropper": "~1.0",
        "cyneek/yii2-widget-upload-crop": "dev-master",
        "Nemmo/yii2-attachments": "*",
        "2amigos/yii2-file-input-widget": "*",
        "rkit/yii2-ajaxform-plugin": "^0.0.4",
        "nsept/yii2-birthday-picker": "*",
        "bryglen/yii2-apns-gcm": "1.0.4"
    ,
    "require-dev": 
        "yiisoft/yii2-codeception": "*",
        "yiisoft/yii2-debug": "*",
        "yiisoft/yii2-gii": "*",
        "yiisoft/yii2-faker": "*"
    ,
    "config": 
        "process-timeout": 1800
    ,
    "scripts": 
        "post-create-project-cmd": [
            "yii\\composer\\Installer::postCreateProject"
        ]
    ,
    "extra": 
        "yii\\composer\\Installer::postCreateProject": 
            "setPermission": [
                
                    "runtime": "0777",
                    "web/assets": "0777",
                    "yii": "0755"
                
            ],
            "generateCookieValidationKey": [
                "config/web.php"
            ]
        ,
        "asset-installer-paths": 
            "npm-asset-library": "vendor/npm",
            "bower-asset-library": "vendor/bower"
        
    

【问题讨论】:

你能把你的composer.json贴在这里吗? 【参考方案1】:

尝试安装资产插件的 dev-master

composer global require "fxp/composer-asset-plugin:dev-master"

它为我们解决了很多问题。

【讨论】:

对我不起作用 :-( ` PHP 7.1.33 (cli) (built: Nov 22 2019 18:28:25) (NTS) Composer version 2.0.8 2020-12-03 17: 20:38`

以上是关于Yii2 与 composer 和 fxp/composer-asset-plugin的主要内容,如果未能解决你的问题,请参考以下文章

composer安装yii2问题总结

Composer 无法安装 yii2 扩展

composer安装yii2.0

Windows环境下Composer的安装和yii2的安装

yii2 composer更新致命错误

yii2_composer安装和改为国内源