作曲家更新 Laravel

2022-01-21 00:00:00 php laravel composer-php

一位开发人员已将他的项目发送给我,但每当我尝试更新或安装我的供应商时,一切都很好,直到最后,它会输出以下消息.

A developer has sent me his project to work with, but when ever I try to update or install my vendors everything works great until the very end and it outputs the message bellow.

C:xampphtdocsBigWaveMediadavinkit>php artisan migrate
{
    "error": {
        "type": "Exception",
        "message": "expected color value: failed at `.clearfix;` C:\xampp\htdocs\BigWaveMedia\davinkit\app\start/../../public/less/style.less on line 102",
        "file": "C:\xampp\htdocs\davinkit\vendor\leafo\lessphp\lessc.inc.php",
        "line": 3258
    }
}
C:xampphtdocsBigWaveMediadavinkit>

有什么想法吗?这是完整的日志 http://pastebin.com/y9q4Rc5z

Any ideas at all? Here is a full log http://pastebin.com/y9q4Rc5z

推荐答案

运行composer update时,composer会生成一个名为composer.lock 列出了你所有的包和当前安装的版本.这允许您稍后运行 composer install,它将安装该文件中列出的包,重新创建您上次使用的环境.

When you run composer update, composer generates a file called composer.lock which lists all your packages and the currently installed versions. This allows you to later run composer install, which will install the packages listed in that file, recreating the environment that you were last using.

从您的日志中可以看出,您的 composer.lock 文件中列出的某些软件包版本不再可用.因此,当您运行 composer install 时,它会报错并失败.这通常没什么大不了的 - 只需运行 composer update,它就会尝试构建一组协同工作的包并编写一个新的 composer.lock 文件.

It appears from your log that some of the versions of packages that are listed in your composer.lock file are no longer available. Thus, when you run composer install, it complains and fails. This is usually no big deal - just run composer update and it will attempt to build a set of packages that work together and write a new composer.lock file.

但是,您遇到了不同的问题.看来,在您的 composer.json 文件中,原始开发人员添加了一些失败的更新前或更新后操作,特别是 php artisan migrate 命令.这可以通过运行以下命令来避免:composer update --no-scripts

However, you're running into a different problem. It appears that, in your composer.json file, the original developer has added some pre- or post- update actions that are failing, specifically a php artisan migrate command. This can be avoided by running the following: composer update --no-scripts

这将运行作曲家更新,但会跳过添加到文件中的脚本.您应该能够以这种方式成功运行更新.

This will run the composer update but will skip over the scripts added to the file. You should be able to successfully run the update this way.

但是,这并不能长期解决问题.有两个问题:

However, this does not solve the problem long-term. There are two problems:

  1. 迁移是为了数据库更改,而不是像编译资产这样的随机事情.完成迁移并从那里删除该代码.

  1. A migration is for database changes, not random stuff like compiling assets. Go through the migrations and remove that code from there.

不应在每次运行 composer update 时编译资产.从 composer.json 文件中删除该步骤.

Assets should not be compiled each time you run composer update. Remove that step from the composer.json file.

根据我的阅读,最佳实践似乎是在开发期间根据需要编译资产(即,当您对 LESS 文件进行更改时 - 理想情况下使用像 gulp.js) 和部署之前.

From what I've read, best practice seems to be compiling assets on an as-needed basis during development (ie. when you're making changes to your LESS files - ideally using a tool like gulp.js) and before deployment.

相关文章