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 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?