What Is New in Laravel 4.0
| Category | Key Changes |
|---|---|
| New Features | Queues, Mail, Soft Deleting, Database Seeding & Migrations, Pagination |
| Architecture | Composer-based, Decoupled Components, IoC Container Foundation |
| Routing | Resource Controllers, Route Filters, HTTPS Routing |
| Database | Eloquent Relationships, Query Scopes, Schema Builder |
| Security | Hashed Password Upgrades, Improved CSRF Protection |
How did Laravel 4.0 change its architecture?
Laravel 4.0 was a complete rewrite built around Composer. The framework was broken into a collection of individual packages, all managed through Composer dependencies. This shift made the core incredibly lightweight and allowed developers to include only the components they needed for a project.
At the heart of this new architecture is the Illuminate support package and a powerful Inversion of Control (IoC) container. In practice, this meant your application was no longer a monolith but a set of interoperable components, giving you far more flexibility.
What new components were introduced?
Several first-party components were introduced to handle common tasks. The queue service provided a unified API for deferring time-consuming jobs, while the mail component simplified sending emails across various drivers.
Soft deleting became a built-in Eloquent trait, allowing records to be "trashed" instead of permanently destroyed. The new paginator offered a simple way to paginate database results, and the schema builder provided database-agnostic tools for managing tables.
How did Eloquent and routing improve?
Eloquent ORM saw massive upgrades. Defining relationships became more intuitive, and query scopes were added for encapsulating common query logic. This made building complex data models much cleaner and more efficient.
Routing gained resource controllers for quick CRUD route mapping and more powerful before/after filters. You could also easily define routes that should exclusively use HTTPS, which was a big step forward for application security.
Example Resource Controller
Route::resource('photos', 'PhotoController');
What were the breaking changes from Laravel 3?
Moving to a Composer-based structure was the biggest breaking change. The entire application folder structure was different, and many class namespaces were updated. The old bundles system was replaced with Composer packages.
Configuration files were moved to a dedicated config directory and became plain PHP arrays instead of the previous serialized format. The Artisan command-line tool was also completely revamped with a new syntax.
FAQ
Was Laravel 4 a complete rewrite?
Yes. Unlike incremental updates, Laravel 4 was a ground-up rewrite designed around Composer. The framework was decomposed into a set of separate, interoperable packages, fundamentally changing how it was structured and distributed.
How do I handle packages and bundles from Laravel 3?
The bundles system from Laravel 3 was entirely removed. You must convert any existing bundles into Composer packages, which are then required in your composer.json file and loaded by the new application structure.
What happened to the old application structure?
The application folder was significantly reorganized. Key changes include moving configuration files to a app/config directory and placing model files directly in the app/models folder instead of within a nested "application" folder.
Is the database migration system different?
Migrations were greatly improved. They are now managed entirely through Artisan commands (migrate, migrate:make), and a new database seeding feature was introduced to populate your database with test data after migrations run.
How do I upgrade my authentication to use bcrypt?
Laravel 4 switched to bcrypt hashing by default. When a user logs in, their old hash (if using the previous method) will be automatically upgraded to bcrypt upon successful authentication, making the transition seamless.