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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵