简体   繁体   中英

PHP Fatal error when trying to install Laravel 5 with Composer

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' sudo find . -print | grep -i 'compiled.php' 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.

The composer file could be very well be 30 days older and not updated.

You would have to run this command from the path of the code folder using either a vitrtual box or cmd/gitbash/terminal:

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

once downloaded, move the composer.phar file to the composer folder , normally its located at:

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

then run the composer update to regenerate the autoloaded files.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM