命令 "clear-compiled" 未定义。Laravel 5.2

5

我正在尝试使用Composer下载Laravel的HTML依赖项。

composer.json在这里:

"name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "illuminate/html": "5.2"
    },

当我运行 composer updatephp composer update 命令时,终端日志显示:

E:\xampp\htdocs\lara-test>composer update
> php artisan clear-compiled

  [InvalidArgumentException]
  Command "clear-compiled" is not defined.

Script php artisan clear-compiled handling the pre-update-cmd event returned with an error

  [RuntimeException]
  Error Output:

update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock]
 [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-
progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader]
 [-a|--classmap-authoritative] [--ignore-platform-reqs] [--prefer-stable] [--pre
fer-lowest] [-i|--interactive] [--] [<packages>]...

什么是缺失的? 请帮忙。


3
尝试运行命令 composer update --no-scripts,请勿运行脚本。 - Drudge Rajen
1
谢谢,它正在工作。但是 --no scripts 是什么意思? - Jitendra
3个回答

13
你可以通过使用 composer update --no-scripts 来解决这个问题,该命令在composer中运行更新命令而不执行composer.json文件中定义的脚本。
在运行 composer update 的过程中会执行一个脚本,该脚本会运行 php artisan clear-compiled 命令,实际上更新工作是正常进行的,只是没有清除编译的文件。
还有一些其他的解决方法,可以参考http://jianjye.com/fix-command-clear-compiled-not-defined-error-upgrading-laravel-5-2/https://github.com/laravel/framework/issues/9678

谢谢,那帮了我很多。 - raphael
@raphael,如果您觉得有帮助的话,是否可以给它点个赞呢? - James

0

当前的答案并不能满足想要执行clear-compiled操作的人。这里提供一个等效脚本的解决方案(取自https://github.com/laravel/framework/issues/9678

在laravel根目录下创建一个名为clear-compiled的脚本,其内容如下:

#!/usr/bin/env php
<?php
foreach (glob(__DIR__ . '/bootstrap/cache/*.*') as $file) {
    @unlink($file);
}
echo 'Cleared compiled directory.';
exit();

然后在 composer.json 文件中,将 php artisan clear-compiled 改为 php clear-compiled
"scripts": {
    "pre-install-cmd": [
        "php clear-compiled"
    ],
    "post-install-cmd": [
        "php clear-compiled"
    ]
},

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接