Learning Laravel the Smart Way: Play with Its Core Packages First!

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() or Model::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

ComponentComposer PackageWhat It Does
Eloquent ORMilluminate/databaseDatabase ORM for interacting with MySQL, SQLite, etc.
Routingilluminate/routingDefine and handle HTTP routes (basic web routing).
Eventsilluminate/eventsCreate and dispatch custom events/listeners.
Containerilluminate/containerLaravel’s powerful service container / dependency injection
Validationilluminate/validationValidate arrays of data with rules (just like in Laravel).
Paginationilluminate/paginationPaginate data (useful with Eloquent or manually).
View (Blade)illuminate/viewUse Laravel’s Blade templating engine standalone.
Filesystemilluminate/filesystemWork with local/S3 file systems, just like Storage::.
Sessionilluminate/sessionManage user sessions.
Supportilluminate/supportHelper classes (like Str, Arr, Collection, etc.).
Maililluminate/mailSend emails using drivers like SMTP or Mailgun.
Queueilluminate/queueDispatch and process background jobs.
Cacheilluminate/cacheStore and retrieve cached data (file, Redis, etc.).
Configilluminate/configLoad and access configuration values.
Logilluminate/logLogging system (based on Monolog).
Consoleilluminate/consoleBuild CLI apps and commands (based on Symfony Console).
Translationilluminate/translationHandle language files and localization.
Encryptionilluminate/encryptionEncrypt and decrypt strings securely.