
Laravel vs plain PHP is a choice between two ways of building with the same language: writing every piece of your website by hand, or starting from a framework that already handles the common jobs for you. Laravel is not a different language. It is a large collection of ready-made PHP code that you build on top of.
This guide walks through both approaches using one simple example: a page that shows a single blog post. You'll see how each handles routing, databases and security, what the speed and cost trade-offs really are, and a simple rule of thumb for picking the right one.
- Plain PHP means you write routing, database code and security checks yourself.
- Laravel is still PHP, with routing, Eloquent, Blade and Artisan doing the repetitive work.
- Plain PHP runs leaner; Laravel usually lets you build and change features faster.
- Both are free and open source, so the real cost is your development time.
- Small one-off script: plain PHP. Real, growing app: Laravel. Learn PHP basics first.
- 0:00Intro
- 0:25Your first site gets messy fast
- 1:24Plain PHP vs Laravel
- 2:21You do everything by hand
- 3:22One request, handled by hand
- 4:11Four tools, built in
- 5:13How Laravel handles a visit
- 6:00Less code, same result
- 7:02Fast to run vs fast to build
- 8:00Both are free — time isn't
- 8:52Conventions keep growing apps tidy
- 9:52The bakery site, built twice
- 10:52Small script? PHP. Real app? Laravel
- 11:45Mistakes beginners often make
- 12:39What you learned today
- 13:19Learn PHP first, then build with Laravel
Why does a plain PHP website get messy?
Imagine building a small website for a friend's bakery in plain PHP. The first page is easy, and it works. Then they ask for a login, an order form and an admin area. This is the point where how you started begins to matter, because every new feature adds more files and more copied code.
Soon the same logic lives in several places. Ten files each check the login a little differently, and fixing a bug on one page breaks another. Every form you write by hand also needs its own protection against tricks like SQL injection and fake form submissions. Forget that protection once, and that page becomes the weak spot attackers look for.
There is also a hidden cost across projects. On each new site, you rebuild the same basics again: routing, database code and logins. That time goes into plumbing rather than into the features that make the site useful.
- Copied code spread across many files
- One fix breaking another page
- Security checks that are easy to forget
- The same basics rebuilt on every project
What is the difference between PHP and Laravel?
PHP is the programming language that runs on the server and builds your web pages. Laravel is a popular, free PHP framework. Both use exactly the same language; the difference is how much you write yourself. A helpful comparison is cooking from raw ingredients versus cooking in a fully equipped kitchen. The food is the same, but the effort is very different.
With plain PHP, you get total control and nothing is hidden, but you also write the routing, database code and security yourself. With Laravel, those pieces already exist, they are tested by a large community, and you follow its conventions to keep a project organised.
The key point for beginners is that Laravel code is still plain PHP underneath. Variables, arrays, functions and classes work the same way inside Laravel, so nothing you learn in plain PHP is wasted.
How a plain PHP page handles a request
Here is a tiny page that shows one blog post, written from scratch. Notice how many jobs this single file does. It reads the id from the web address and forces it to be a number. It writes the SQL query by hand, prepares it safely and runs it. Then it escapes the title before printing it, so nobody can inject harmful code.
Routing in plain PHP simply means each page is its own file, such as post.php. That is easy at first, but clean addresses like /posts/5 need extra server rules you have to set up yourself. The prepared statement and htmlspecialchars call are what keep the page safe, and they only exist if you remember to write them.
Follow one visitor who clicks a link to post 5. Your code reads the URL and gets id 5, builds a SELECT query, finds one row in the database, escapes the output and sends the HTML. None of these steps is hard. The trouble is repeating them on every page, where each copy is another place for a small mistake to slip in.
- Read the URL → id = 5
- Write SQL → SELECT … where id = 5
- Query the database → 1 row found
- Escape output → safe title text
- Send HTML → page shown
# post.php — one page, every job
$id = (int) ($_GET['id'] ?? 0);
$sql = 'SELECT * FROM posts WHERE id = ?';
$s = $pdo->prepare($sql); $s->execute([$id]);
$post = $s->fetch();
echo htmlspecialchars($post['title']);
Laravel's four built-in tools
Laravel replaces those repeated chores with four main tools. The router decides which code runs for each web address. Eloquent fetches and saves your data. Blade turns that data into safe HTML. Artisan creates new files for you on command, so you don't have to set up boilerplate by hand.
Eloquent is worth a closer look. Instead of writing SQL strings, you ask for Post::find(5). Eloquent builds a safe query, runs it and hands the post back as a simple PHP object. Blade escapes anything you print inside double curly braces, so the safety step happens automatically.
When the same request for post 5 reaches a Laravel app, each job goes to its own part. The browser asks for /posts/5, the router calls a controller, the controller asks Eloquent for the post, Eloquent runs a safe query, and a Blade view sends finished HTML back. Because each job has its own home, debugging is simpler: if the page looks wrong, check the view; if the data is wrong, check the model.
- Router: maps web addresses to code
- Eloquent: reads and saves data safely
- Blade: auto-escaped HTML templates
- Artisan: one-line code generators
The same page in Laravel: less code, same result
This is the same post page rebuilt the Laravel way. The three jobs are still there, routing, the database and safe output, but each now takes a single line. The route says that /posts/ followed by any id runs a small function. Post::findOrFail fetches the row, or shows a proper not-found page if it doesn't exist. The view then prints the title inside double curly braces, already escaped.
You didn't write a prepared statement or call htmlspecialchars, yet both protections are in place. Laravel makes the safe way the easy way, which matters most on the tired evening when you would otherwise forget. And because every Laravel app follows the same patterns, a new teammate can find things quickly.
# routes/web.php
Route::get('/posts/{id}', function ($id) {
$post = Post::findOrFail($id);
return view('post', ['post' => $post]);
});
# post.blade.php: {{ $post->title }}
Is Laravel slower than plain PHP?
A little, yes, but it helps to separate two kinds of speed. Running speed is how quickly the server answers a visitor. Building speed is how quickly you, the developer, can finish and change features. Plain PHP usually wins the first race, and Laravel usually wins the second.
A plain PHP script loads only the code you wrote, so each request involves very little extra work. For a tiny job, like a simple contact form handler, that leanness is a real advantage. Laravel loads its framework on every request, which adds some overhead, but its built-in caching commands help keep typical sites fast. For most websites, the speed of building matters more.
Is Laravel free to use?
Yes. Both PHP and Laravel are free and open source, which means the code is public and anyone can use it, read it and improve it. You can use PHP for personal or business projects without paying a licence fee, and most web hosts already have it installed.
Laravel doesn't have a paid version you need to build a real app. Some optional paid services exist around it, such as hosting tools, but the framework itself costs nothing. The real difference is time. Logins, password resets and form validation come ready to use in Laravel, while in plain PHP you would write and test each one yourself, and those hours add up quickly.
When should you use plain PHP or Laravel?
Laravel follows conventions: agreed places and names for everything. Every Laravel project shares the same layout, with models and controllers in app, web addresses in routes, views in resources and table changes in database. It works like a kitchen where the spoons are always in the same drawer, so anyone who joins knows where to look. For one small job, though, those folders just get in the way, and a single readable PHP file is perfectly fine.
Back to the bakery. Its most important page is the order form. In Laravel, validation checks the name, date and quantity with a short list of rules, CSRF protection against forged submissions is built in, and the controller saves the order and sends an email alert using built-in mail tools. In plain PHP, every one of those pieces is yours to build and test, which is doable but takes days of careful work.
To decide, ask two questions: how big will this get, and how long will it live? A one-off small script you'll rarely touch suits plain PHP. A real application with users, data and features that keep growing suits Laravel.
- Plain PHP fits: a script that emails you a form, a nightly task, a quick experiment
- Laravel fits: an online shop, a booking system, a membership site, team projects
Common mistakes beginners make
The first mistake is jumping into Laravel without knowing PHP. Everything feels like magic and errors make no sense. The fix is to learn variables, arrays, functions and classes first, so Laravel's code reads clearly. The second mistake is writing plain PHP without its safety steps, such as gluing user input straight into a query. Always use prepared statements and escape every value you print.
The third mistake is choosing the wrong-sized tool: setting up all of Laravel for a ten-line script, or growing a large shop in messy plain PHP files. When in doubt, return to the rule of thumb and match the tool to the size and lifespan of the project.
- Learning Laravel before PHP basics
- Putting user input straight into SQL or HTML
- Using a full framework for a tiny script, or the reverse
Key takeaways
- Plain PHP gives you full control and full responsibility for every piece.
- Laravel is still PHP, with routing, Eloquent, Blade and Artisan handling repetitive work.
- Laravel makes safe queries and escaped output the default.
- Plain PHP runs leaner; Laravel usually helps you build faster.
- Both are free, so the real cost is your development time.
- Learn PHP basics first, then use Laravel for real, growing apps.
Frequently asked questions
Should I learn PHP before Laravel?
Yes. Laravel is written in PHP, so variables, arrays, functions and classes all carry over. Without those basics, Laravel can feel like magic and its errors are hard to understand.
Is Laravel a programming language?
No. Laravel is a framework, a large collection of ready-made PHP code you build on top of. The code you write in a Laravel project is still PHP.
Is plain PHP less secure than Laravel?
Plain PHP can be secure, but only if you remember prepared statements, output escaping and protection against forged forms on every page. Laravel builds these protections in by default, so they are harder to forget.
Does Laravel make a website slow?
Laravel loads its framework on every request, which adds some overhead compared with a lean PHP script. Its built-in caching commands help keep typical sites fast, and for most projects the time saved in development matters more.
When is plain PHP the better choice?
Plain PHP suits small, self-contained, one-off jobs such as a form handler, a nightly scheduled task or a quick experiment. For these, a single file you can read top to bottom is simpler than a full framework.