我正在尝试运行composer来安装Laravel 5.0.14,并尝试使用Jenkins php模板在Jenkins中测试此代码。
每当我运行composer update
时,我都会得到以下错误:
错误输出:PHP致命错误:调用未定义的方法Illuminate\Foundation\Application::redirectIfTrailingLash()在第16行的/var/lib/jenkins/jobs/Demo/workspace/bootstrap/start.php中
如果我在start.php中删除了有问题的行,我在尝试运行composer update
:时会得到以下错误
错误输出:PHP可捕获的致命错误:参数1已传递给Illuminate\Foundation\Application::detectEnvironment()必须是在中调用的Closure数组diven的实例/第32行的var/lib/jenkin/jobs/Demo/workspace/bootstrap/start.php并在中定义/var/lib/jenkins/jobs/Demo/workspace/vender/laravel/framework/src/IIlluminate/Foundation/Application.php在线402
这是我的composer.json文件:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "5.0.14",
"phpunit/phpunit": "4.7.*@dev",
"theseer/fxsl": "1.0.*@dev",
"theseer/phpdox": "0.6.6",
"squizlabs/php_codesniffer": "1.4.6",
"phpmd/phpmd": "2.0.0",
"h4cc/phpqatools": "dev-master",
"phploc/phploc": "2.0.2",
"sebastian/phpcpd": "2.0.1",
"monolog/monolog": "1.13.0",
"patchwork/utf8": "1.2.1",
"phpdocumentor/phpdocumentor": "v2.0.1",
"mayflower/php-codebrowser": "1.1.0-beta1",
"pear/console_commandline": "dev-trunk",
"pear/log": "dev-master",
"pear/pear_exception": "1.0.0",
"phing/phing": "2.6.1"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "dev"
}
我可以运行composer update --no-scripts
。
我已经搜索了任何带有sudo find . -print | grep -i 'compiled.php'
的composer.php文件。我唯一拥有的是
/vendor/symfony/dependent-injection/Tests/Fixtures/php/services9_compied.php,该文件与compiled.php文件不一致,其他一些人建议为其他有此问题的人删除该文件。
我认为您使用的是Laravel 4 composer.json。从Laraver 4到Laravel 5的一个重大变化是名称空间的使用。此外,许多路径也被修改了,所以仅仅在现有的Laravel 4上安装Laravel 5是不可能的。最好安装一个新的Laravel 5并遵循此指南:http://laravel.com/docs/master/upgrade#upgrade-5.0
这里是我的composer.json(注意自动加载部分中的psr-4)
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.0.*",
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php -r "copy('.env.example', '.env');"",
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
composer文件很可能早了30天而没有更新。
您必须使用vittual box或cmd/gitbash/terminal:从代码文件夹的路径运行此命令
curl -sS https://getcomposer.org/installer | php
下载后,将composer.phar文件移到composer文件夹中,通常位于:
sudo mv composer.phar usr/bin/local/composer
然后运行CCD_ 5以重新生成自动加载的文件。