双路由支持PHP的两个MVC模式

I have a legacy framework that is php <= 5.3.2 approx with MySQL 5.2.1 (real legacy here) - that is not even PSR-0 compliance.

My goal is to transition out of the framework BUT there are over 1000 files involved - so recoding it for now is not an option.

So my solution for now is to have two fold routing:

Step 1: if routing matches - use framework 1 (consider Laravel) step 2: if routing doesn't match - use legacy framework.

This way - anything that is "new" that is to be develop we can use the newer framework's feature - while still operating the old one until we can phase it out eventually.

My question now is: what is the proper way to have the newer framework be the dominant framework and have the legacy be the fall back so that eventually when i've transictioned 75% of the code I'll just display a 404 at that point.

The Legacy routing is: /controller/action so for each route - there must be a controller and action function then if needed queries. What this means is that the routing is dependent on a controller / action and an associated view (ie you make a controller name foo, action bar, to get foo/bar) in comparison to Laravel where you can specify routing aliases and then associate a controller/action to it (ie if you create a controller and several functions - you dont necessary gain controller/action routing without editing the routes.php)

The legacy code has an index.php with a reference to a bootstrap that looks for class to load and environment configuration variables.

I have been doing the same and considered a few solutions, though I don't understand what you mean by 'The Legacy routing is: /controller/action'.

I would say the best way to have Laravel the more dominant is have all requests go through Laravel and at the end of the routes.php have a catch all route e.g.

Route::any('{all}', function($uri)
{
    // Do stuff
})->where('all', '.*'); 

In the catch all you would want to load the legacy routing, this might involve includes or whatever.

By doing this your app runs through all your Laravel routes, and if none of them match it assumes its a legacy route.

The downside with doing it this way would be that all your requests for the legacy code are loading Laravel unnecessarily.

Alternative solutions would be using htaccess to either load legacy or laravel (works best if your site does not have SEO friendly URLs) or putting logic in the app/start/global.php to decide if this request should continue loading Laravel or load legacy.

Hope this helps, feel free to post more information

If it is possible to have a URI trick it would help you a lot. Something like:

Route::group(array('prefix'=>'-'), function() {

 Route::get('/new-framework-route', 'NewController@action');

});

so any request starting with a - would go to the new framework, i.e. /-/users/ etc. Otherwise the legacy framework would handle it.