简体   繁体   English

从4.1升级到4.2后,Laravel控制器路由中断

[英]Laravel controller routing broken after upgrading from 4.1 to 4.2

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. 我有一个laravel项目,可以在laravel 4.1.31上很好地运行,现在我面临的挑战是将该项目迁移到更高版本,例如5.3。 I started following the upgrade guide provided by Laravel on this link below 我开始在下面的此链接上遵循Laravel提供的升级指南

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

I changed the laravel version on composer.json to 4.2.* as shown below 我将composer.json上的laravel版本更改为4.2。*,如下所示

my composer.json file 我的composer.json文件

 { "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. 成功更新 Composer之后,我按照文档进行操作,并将新的Encryption Defaults添加到指定的app / config / app.php文件中。 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 :) :) 带着所有的兴奋,我接下来跑了作曲家dump-autoload,之后我又一次又一次地跑了php artisan dump-autoload :) :) :)

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 最后以勇气用我的项目URL打开了镶边:(它加载了一个我最初不喜欢的页面,Whoops错误页面说

Symfony \\ Component \\ Debug \\ Exception \\ FatalErrorException (E_UNKNOWN) Symfony \\组件\\调试\\异常\\ 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. 通过该实验,我发现应用程序未加载DashboardController或与此相关的任何其他控制器。 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 :) 很高兴接受您提供的所有帮助:)

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. 使用静态文件详细信息更新我的composer.json解决了我的问题,该应用程序损坏了,因为缺少了这些autload-files类,这些类用于在自动加载类时实例化其他控制器文件。

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"

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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