我正在尝试使用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:\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>]...
缺少什么? 请帮忙。
答案 0 :(得分:10)
您可以使用YOUR_CONSTANT = "constant_value"
来解决此问题,该from appconfigurations import *
def your_view(request):
constant = YOUR_CONSTANT
运行来自composer的更新命令,而不执行composer update --no-scripts
文件中定义的脚本。
作为运行composer.json
的一部分,执行一个运行composer update
的脚本 - 实际上更新正常工作,只是没有清除编译文件。
有关于其他工作的几篇博文:http://jianjye.com/fix-command-clear-compiled-not-defined-error-upgrading-laravel-5-2/并且已记录问题https://github.com/laravel/framework/issues/9678
答案 1 :(得分: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"
]
},
答案 2 :(得分:0)
将旧项目从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/