我正在尝试使用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 update
或php composer update
时,终端日志是:
E:xampphtdocslara-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
来解决此问题,该 从作曲家运行 update 命令,而无需执行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
> 这里的当前答案并不能满足想要执行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"
]
},
将旧项目从 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/