douya2007 2016-10-14 08:27
浏览 68
已采纳

从4.1升级到4.2后,Laravel控制器路由损坏

I have a laravel project which runs perfectly fine on laravel 4.1.31 , now my challenge was to migrate that project to higher version say 5.3. I started following the upgrade guide provided by Laravel on this link below

https://laravel.com/docs/5.3/upgrade#upgrade-4.2

I changed the laravel version on composer.json to 4.2.* as shown below

my composer.json file

{
    "require": {
        "classpreloader/classpreloader": "1.0.2",
        "d11wtq/boris":"1.0.8",
        "filp/whoops":"1.0.10",
        "ircmaxell/password-compat":"1.0.4",
        "jeremeamia/SuperClosure":"1.0.2",
        "laravel/framework":"4.2.*",
        "monolog/monolog":"1.15.0",
        "nesbot/carbon":"1.17.0",
        "nikic/php-parser":"v0.9.5",
        "patchwork/utf8":"v1.1.30",
        "phpseclib/phpseclib":"0.3.10",
        "predis/predis":"v0.8.7",
        "psr/log":"1.0.0",
        "spipu/html2pdf":"4.5.0",
        "stack/builder":"1.0.3",
        "swiftmailer/swiftmailer":"5.4.1",
        "symfony/browser-kit":"2.4.10",
        "symfony/console":"2.4.10",
        "symfony/css-selector":"2.4.10",
        "symfony/debug":"2.4.10",
        "symfony/dom-crawler":"2.4.10",
        "symfony/event-dispatcher":"2.7.3",
        "symfony/filesystem":"2.7.3",
        "symfony/finder":"2.4.10",
        "symfony/http-foundation":"2.4.10",
        "symfony/http-kernel":"2.4.10",
        "symfony/process":"2.4.10",
        "symfony/routing":"2.4.10",
        "symfony/security-core":"2.4.10",
        "symfony/translation":"2.4.10",
        "tappleby/laravel-auth-token":"0.3.4",
        "tecnickcom/tcpdf":"6.2.12",
        "way/generators": "2.*"
    },
    "autoload": {
        "files": [
            "app/libraries/DashboardInit.php",
            "app/libraries/MailSmsHandler.php",
            "app/libraries/Twilio.php",
            "app/libraries/class.phpmailer.php",
            "app/libraries/class.smtp.php",
            "app/libraries/php-excel.php"
        ],
        "classmap": [
            "app/commands",
            "app/controllers",
            "app/models",
            "app/database/migrations",
            "app/database/seeds"
        ]
    },
    "repositories": {
        "packagist": { "url": "https://packagist.org", "type": "composer" }
    }
}

After successful composer update I followed the documentation and added new Encryption Defaults to the specified app/config/app.php file. and the next steps were not applicable in my case so i skipped them.

With all the excitement i ran composer dump-autoload next after which i also ran php artisan dump-autoload without fail again and again :) :)

and finally with courage opened the chrome with my project url :( it loads a page which i didn't like at first a Whoops error page saying

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN)

It doesn't give much information about the error. I tried to debug through my routes file with this code.

Route::get('/login', function(){
$environment = App::environment();
    echo $d =  class_exists('DashboardController');
    $d = new DashboardController();
    $c = get_declared_classes();
    sort($c);
    dd($c);
});

By this experiment I found out that application is not loaded with DashboardController, or any other controller for that matter. I have tried many things with composer and artisan cache clearing, optimizing but no luck so far leading me to post this question.

Glad to take all the help you people offer :)

</div>
  • 写回答

1条回答 默认 最新

  • dongxing1960 2016-10-14 11:39
    关注

    Updating my composer.json with the static files details solved my issue the app was broken because these autload-files classes were missing which used to instantiate the other controller files while autloading of classes.

    Thank you for your time. Sorry to ruin your time due to this stupid question.

    {
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "require": {
        "laravel/framework": "4.2.*",
        "tappleby/laravel-auth-token": "0.3.*",
        "spipu/html2pdf": "~4.5"
    },
    "autoload": {
        "classmap": [
            "app/commands",
            "app/controllers",
            "app/models",
            "app/libraries",
            "app/database/migrations",
            "app/database/seeds",
            "app/tests/TestCase.php"
        ],
         "files": [
            "app/libraries/DashboardInit.php",
            "app/libraries/MailSmsHandler.php",
            "app/libraries/Twilio.php",
            "app/libraries/class.phpmailer.php",
            "app/libraries/class.smtp.php",
            "app/libraries/php-excel.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 artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "stable"
    

    }

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于双目测规则物体尺寸
  • ¥15 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,