Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an upgrade guide from Laravel 3 to Laravel 4?

I've got a webpage written in L3 and I feel that it's on time to move it forward to L4. So I'm searching for a howto-guide telling me the porting process. In which folders my old files belonges now into and which parts of code have to be rewritten, syntax changes and so on.

like image 643
Hexodus Avatar asked Dec 25 '22 20:12

Hexodus


2 Answers

James Gordon wrote a nice blog post detailing the various sections that would need to be changed.

Upgrading from Laravel 3 to Laravel 4

It took roughly three full days of effort (lets call that 24 hours) to convert the application from Laravel 3 to Laravel 4. Not including app/config, app/lang, app/tests or any other Laravel code that exists in the project structure, both projects consisted of a little over 2,500 lines of code. The exact line counts for the original project are as follows:

Folder LOC controllers 540 helpers 183 models 927 tasks 384 views 476 Total 2,510

like image 156
ralphowino Avatar answered Feb 07 '23 05:02

ralphowino


Official changelog should help you.

Also don't forget to change your method names. All snake_case method names are converted to camelCase.

Edit: folder names are almost same. application folder became app, model, view and controllers' folders' paths are still same under the app folder. Migrations are now in app/database/migrations folder.

Routing has changed a bit. the :num, :all etc is dropped, now you can name them anything, and set their rules with regex.

E.g: This:

Route::get('my/method/(:num)', array('as' => 'name', 'uses' => 'controller@method'));

became like this:

Route::get('my/method/{id}', array('as' => 'name', 'uses' => 'yourController@yourMethod'))->where('id','[0-9]+');

(id is not a must, you can name it anything.)

Route::get('my/method/{foo}', array('as' => 'name', 'uses' => 'yourController@yourMethod'))->where('foo','[0-9]+');

For the filters, you can now use app/filters.php instead of putting them into your routes.php.

like image 32
Arda Avatar answered Feb 07 '23 04:02

Arda