VOOZH about

URL: https://thenewstack.io/introduction-to-laravel-for-ruby-on-rails-or-django-fans/

⇱ Introduction to Laravel for Ruby on Rails or Django Fans - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2024-10-05 05:00:02
Introduction to Laravel for Ruby on Rails or Django Fans
tutorial,
Frontend Development / Programming Languages

Introduction to Laravel for Ruby on Rails or Django Fans

If you’ve used Rails or Django before, check out our guide to Laravel — a more modern Model-View-Controller (MVC) based web framework.
Oct 5th, 2024 5:00am by David Eastman
👁 Featued image for: Introduction to Laravel for Ruby on Rails or Django Fans
Photo by Thom Law on Unsplash.
Having developed for Ruby on Rails when it was cool, I certainly recognize who Laravel is attempting to attract by referring to a “web application framework with expressive, elegant syntax.” I don’t know PHP, but I don’t envisage the jump to be too hard. And while PHP usage is declining, it is still used on about 30 million websites — so it is worth learning. One of the advantages that “older” languages have in the era of LLMs is that developers effectively have a Rosetta stone to help with understanding. If you’ve used Rails (or Django) then this guide should be going at your speed. Laravel is also Model-View-Controller (MVC) based, and there is an Object Relational Model built in. I can also already see references to “migrations”, so let’s go.

Go With the Herd

Laravel uses an installer, version management and environment controller called Herd. One of Ruby’s weaknesses was always versioning and environment control; I suspect I used a different combination for every project — so an all-in package with binaries is perfectly welcome. I installed the Mac version of the Herd app on my trusty old MacBook. 👁 Image
They also use this to remind you that there’s a Pro version. After the install, all the relevant binaries are available in my terminal: 👁 Image
We learn that Laravel refers to “parked directories” that can contain projects that will be supported in Laravel by default. First of all, let’s get a template project up and running and look at the structure:
> composer create-project laravel/laravel example-app
What we see in our example-app directory is familiar: 👁 Image
(You don’t have to look far back to see where I have written about Vite, if you are wondering what that last configuration is.) Let’s quickly serve this up with artisan before we dig into the code: 👁 Image
Not much feedback there! But we see a simple front page with some pointers to docs: 👁 Image
At the bottom is a mention of the Laravel version, v11.26.0 — what I had above was the version of the Laravel installer. OK, back to the code. The file that ties in the application and the server is the .env file. Since this dictates how you, as a developer, see things, you don’t want to check this in for a team. I’ll mirror a few of the important lines:
APP_NAME=Laravel
APP_ENV=local
APP_DEBUG=true
APP_URL=http://localhost

APP_MAINTENANCE_DRIVER=file
# APP_MAINTENANCE_STORE=database

DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=

Routing

Inside the routes directory lives the web.php file that defines our application routes. These link HTTP requests with your code — so it’s rather central to any web application. There is only one route in our example, which is a php closure:
<?php 

use IlluminateSupportFacadesRoute; 

Route::get('/', function () { 
 return view('welcome'); 
});
This links the home page with the “welcome” view. So let’s find that. Views live in the resources/view directory. Laravel uses the blade templating language, so our welcome file is welcome.blade.php. This is too ugly to list, so lets make a simple view to make sure we grok. I’ll create the simple view file resources/views/greeting.blade.php:
<html> 
 <body> 
 <h1>Hello, {{ $name }}</h1> 
 </body> 
</html>
You can recognize the variable $name inserted into the HTML. If we want to see this, we need to create a route. So we’ll add the following route into web.php:
Route::get('/greeting', function () { 
 return view('greeting', ['name' => 'TheNewStack']); 
});
This should allow us to resolve the url /greeting while showing the greeting. This worked immediately… 👁 Image
…with the expected confirmation of the call in my still-running local server terminal tab. Of course, we also want to work with the other bits in MVC — namely, models and controllers.

Seeding

If we look in the database directory, we can see that there are three migrations, along with a SQLite database. Using my limited SQLite skills, I could see that the migrations have taken place, but there is no user data as yet. 👁 Image
This is what the user table looks like from SQLite:
CREATE TABLE IF NOT EXISTS "users" 
("id" integer primary key autoincrement not null, 
 "name" varchar not null, 
 "email" varchar not null, 
 "email_verified_at" datetime, 
 "password" varchar not null, 
 "remember_token" varchar, 
 "created_at" datetime, 
 "updated_at" datetime);
CREATE UNIQUE INDEX "users_email_unique" on "users" ("email");
There is no actual data, however. Within the seeders directory lies this code, clearly designed to add one user entry using the user model’s factory: 👁 Image
Using the server tool, I ran this: 👁 Image
Running the select statement again in SQLite proved that data had indeed been added. There is a user model file, but the code just nods through the database definition that we can already see from the user schema. So we have a user model and some data. We need to add a controller, as none is present in the example. Let’s try something simple. First, we can create the file itself using artisan: 👁 Image
I can then put some example code into that file:
<?php 

namespace AppHttpControllers; 
use AppModelsUser; 
use IlluminateViewView; 

class UserController extends Controller { 
 /** * Show the profile for a given user. */ 
 public function show(string $id): View { 
 return view('user', [ 
 'user' => User::findOrFail($id) 
 ]); 
 } 
}
Then, we can add a route:

use AppHttpControllersUserController;
...
Route::get('/user/{id}', [UserController::class, 'show']);
Similarly, I’ll ask artisan to create a user view: 👁 Image
I’ll put enough in it, based on what I saw in the seeder:
<div> 
 <html> 
 <body> 
 <h2>User {{$user->id}}</h2> 
 <h3>Name: {{$user->name}}</h3> 
 <h3>Email: {{$user->email}}</h3> 
 </body> 
 </html> 
</div>
We get what we expect immediately: 👁 Image

Conclusion

Now this all goes to show that Laravel is indeed sufficiently similar to Rails that you can just use it. But take time to read about the differences; most agree that Laravel is more scalable, for example. Much as I love Ruby, it has quite a deep meta-programming model that is not easy to pick up. Laravel is newer and has had time to observe the web landscape. Either way, it is definitely worth trying it out if you are looking for an established web platform for a dedicated project.
TRENDING STORIES
David has been a London-based professional software developer with Oracle Corp. and British Telecom, and a consultant helping teams work in a more agile fashion. He wrote a book on UI design and has been writing technical articles ever since....
Read more from David Eastman
SHARE THIS STORY
TRENDING STORIES
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.