【问题标题】:Command "clear-compiled" is not defined. Laravel 5.2命令“clear-compiled”未定义。拉拉维尔 5.2
【发布时间】:2016-07-30 14:19:13
【问题描述】:

我正在尝试使用 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>]...

缺少什么? 请帮忙。

【问题讨论】:

  • 试试composer update --no-scripts
  • 谢谢,它的工作。但是--no scripts 是什么??

标签: php command composer-php laravel-5.2


【解决方案1】:

您可以通过使用composer update --no-scripts 来解决此问题,该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 如果你觉得它有帮助你介意投票吗?
【解决方案2】:

这里的当前答案不能满足想要执行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"
    ]
},

【讨论】:

    【解决方案3】:

    在将旧项目从 Laravel 5.1 迁移到 5.2 时,我遇到了同样的错误。解决方案正在运行:

    $ rm -Rf bootstrap/cache/*
    

    这将手动清除缓存,php artisan clear-compiled 将再次起作用。

    参考:https://jianjye.com/p/fix-command-clear-compiled-not-defined-error-laravel/

    【讨论】:

      猜你喜欢
      • 2019-05-26
      • 1970-01-01
      • 2017-03-16
      • 2018-10-14
      • 2021-12-30
      • 2018-02-11
      • 2014-10-24
      • 2018-05-23
      • 2021-08-14
      相关资源
      最近更新 更多