dqwh1201 2015-06-26 21:19
浏览 196
已采纳

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

I'm trying to run composer to install Laravel 5.0.14, and am also trying to test this code out in Jenkins using the Jenkins php-template.

Whenever I run composer update, I get the following error:

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

If I remove the offending line in start.php, I obtain the following error when attempting to run 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

This is my composer.json file:

{
    "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"
}

I can run composer update --no-scripts.

I've searched for any composer.php files with sudo find . -print | grep -i 'compiled.php'. The only one I have is

./vendor/symfony/dependency-injection/Tests/Fixtures/php/services9_compiled.php
which does not correspond with the compiled.php file several other people have suggested deleting for other people who have had this problem.
  • 写回答

2条回答 默认 最新

  • doujiang2020 2015-06-27 01:00
    关注

    I think you are using a Laravel 4 composer.json. One of the big changes from Laravel 4 to Laravel 5 is the usage of namespaces. Also a lot of paths have been modified, so just installing Laravel 5 over an existing Laravel 4 is not possible. Better to install a fresh Laravel 5 and follow this guide: http://laravel.com/docs/master/upgrade#upgrade-5.0

    For reference here is my composer.json (notice the psr-4 in the autoload section)

    {
    "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"
    }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题