A Laravel-Rails Dictionary

Sometimes you struggle for a long time to learn something, and you don't feel like you've really made much progress. But when you learn something new and somewhat similar to it, the learning curve is greatly reduced. It's a great feeling. That's what happened with me recently when I tried to learn Laravel for a work project. Because of the time I spent with Rails, it made learning Laravel so much easier! Laravel is a MVC framework for PHP very similar to the way Rails is for Ruby.

Because a lot of the concepts are similar, I created a chart of equivalent syntaxes that could get someone who is already familiar with Rails started in Laravel much quicker.

Laravel Rails
composer install (or php composer.phar install) gem install
composer create-project laravel/laravel your-project-name rails new your-project-name
composer.json Gemfile
composer.lock Gemfile.lock
packagist.org rubygems.org
blade erb or haml
Eloquent ActiveRecord
php artisan serve rails serve
php artisan make:controller PagesController rails generate controller Pages
php artisan make:model Article rails generate model Article
php artisan make:migration add_column_to_table rails generate migration AddColumnToTable
php artisan migrate bundle exec rake db:migrate
php artisan tinker rails console
php -a irb
php artisan route:list bundle exec rake routes

Overall, I really love Laravel. In fact, I think I like Laravel more than Rails (while I still like Ruby way more than PHP). There are obviously a lot of similarities to Rails, and you can't take away the fact that Rails changed the landscape and paved the way for Laravel. But there are also many things that are different as well, and make Laravel really shine. I'll try to write about those in a future post.

Meanwhile, here are a few shout-outs: