When I started exploring Laravel, I quickly realized that it comes with a lot of powerful features — models, database queries, facades, validation, routing, and so on.
But instead of jumping straight into the full framework, I decided to take a step back and understand how Laravel works behind the scenes. The result? A much clearer understanding of Laravel’s core building blocks.
🎯 Why Try This Approach?
Laravel is built on top of many excellent PHP packages — most of which you can use outside of Laravel. One of them is the Eloquent ORM, which handles database operations. I wanted to see if I could use Eloquent in a plain PHP script — no Laravel framework — and it turns out, you can!
🛠️ What I Did
I created a simple PHP script and used Composer to install the Eloquent package:
composer require illuminate/database
Then, I wrote a basic script that connects to a database and uses Eloquent just like you would in Laravel:
<?php
require 'vendor/autoload.php';
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Database\Eloquent\Model;
// Set up database connection
$capsule = new Capsule;
$capsule->addConnection([
'driver' => 'mysql',
'host' => '127.0.0.1',
'database' => 'test_db',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]);
$capsule->setAsGlobal();
$capsule->bootEloquent();
// Create a model
class User extends Model {
protected $table = 'users';
protected $fillable = ['name', 'email'];
}
// Use Eloquent methods
$user = User::create([
'name' => 'John Doe',
'email' => 'john@example.com'
]);
$found = User::find(1);
echo $found->name;
This script works exactly like it would inside a Laravel app — but it’s just plain PHP!
💡 What I Learned
- Eloquent is just a package — Laravel simply gives it a nice structure.
- Laravel’s magic is mostly built from independent components like this.
- I didn’t need the full framework to understand how
Model::create()orModel::find()works. - This made it much easier to understand Laravel models, facades, and even the service container later.
🚀 Final Thoughts
Before diving into Laravel itself, I highly recommend trying out its individual packages in small PHP projects. Whether it’s Eloquent, Validation, Routing, or others — you’ll gain a deeper, clearer understanding of how things work under the hood.
Laravel becomes a lot less magical when you see that it’s just smart packaging of powerful tools you can use directly.
Happy experimenting! 🔧😊
Check this git repo : https://github.com/mikegsmith76/laravel-standalone
✅ Popular Laravel Components to Try in Standalone PHP
| Component | Composer Package | What It Does |
|---|---|---|
| Eloquent ORM | illuminate/database | Database ORM for interacting with MySQL, SQLite, etc. |
| Routing | illuminate/routing | Define and handle HTTP routes (basic web routing). |
| Events | illuminate/events | Create and dispatch custom events/listeners. |
| Container | illuminate/container | Laravel’s powerful service container / dependency injection |
| Validation | illuminate/validation | Validate arrays of data with rules (just like in Laravel). |
| Pagination | illuminate/pagination | Paginate data (useful with Eloquent or manually). |
| View (Blade) | illuminate/view | Use Laravel’s Blade templating engine standalone. |
| Filesystem | illuminate/filesystem | Work with local/S3 file systems, just like Storage::. |
| Session | illuminate/session | Manage user sessions. |
| Support | illuminate/support | Helper classes (like Str, Arr, Collection, etc.). |
illuminate/mail | Send emails using drivers like SMTP or Mailgun. | |
| Queue | illuminate/queue | Dispatch and process background jobs. |
| Cache | illuminate/cache | Store and retrieve cached data (file, Redis, etc.). |
| Config | illuminate/config | Load and access configuration values. |
| Log | illuminate/log | Logging system (based on Monolog). |
| Console | illuminate/console | Build CLI apps and commands (based on Symfony Console). |
| Translation | illuminate/translation | Handle language files and localization. |
| Encryption | illuminate/encryption | Encrypt and decrypt strings securely. |
