尝试使用Composer安装Laravel 5时出现PHP致命错误

时间:2015-06-26 21:19:56

标签: php laravel jenkins laravel-5 composer-php

我试图运行composer来安装Laravel 5.0.14,并且还尝试使用Jenkins php-template在Jenkins中测试这段代码。

每当我运行composer update时,我都会收到以下错误:

Error Output: PHP Fatal error: Call to undefined method 
Illuminate\Foundation\Application::redirectIfTrailingSlash() 
  in /var/lib/jenkins/jobs/Demo/workspace/bootstrap/start.php on line 16

如果我删除start.php中的违规行,尝试运行composer update时会出现以下错误:

Error Output: PHP Catchable fatal error: 
  Argument 1 passed to Illuminate\Foundation\Application::detectEnvironment() 
   must be an instance of Closure, array diven, called in 
   /var/lib/jenkins/jobs/Demo/workspace/bootstrap/start.php on line 32 
     and defined in 
   /var/lib/jenkins/jobs/Demo/workspace/vendor/laravel/framework/src/Illuminate
   /Foundation/Application.php
 on line 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/dependency-injection/Tests/Fixtures/php/services9_compiled.php
,这与其他几个人建议删除已经遇到此问题的其他人的compiled.php文件不符。

2 个答案:

答案 0 :(得分:0)

作曲家文件可能已经过了30天,而且没有更新。

您必须使用vitrtual box或cmd / gitbash / terminal从代码文件夹的路径运行此命令:

curl -sS https://getcomposer.org/installer | php

下载后,将composer.phar文件移动到composer文件夹,通常位于:

sudo mv composer.phar usr/bin/local/composer

然后运行composer update以重新生成自动加载的文件。

答案 1 :(得分:0)

我认为你正在使用Laravel 4 composer.json。从Laravel 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"
}
}