Many developers start their careers a little unsure of which frameworks to specialize in. Even when they might have decided on a programming language, the constant new releases of exciting new frameworks and updates to existing ones constantly hitting the market make the decision really challenging.
One framework many developers choose to learn or work with at some point in their careers is Laravel. Although originally released over a decade ago, Laravel is still thriving with updates.
What is Laravel?
At its core, Laravel is an open-source PHP framework designed to help developers create web apps more easily through a wealth of built-in features. Originally released in 2011, creator Taylor Otwell began its development to provide an alternative to the existing Codeigniter framework. Since then, Laravel has gone through 8 different versions with smaller updates released on a more regular basis.
Laravel is a server-side PHP framework. This means developers have the ability to build full-stack applications with features that typically require a backend, including exports, accounts, and order management.
Developers choose to widely use Laravel for a variety of different reasons, but mainly because of the following features:
- Modular packaging system with dependency management – This allows developers to easily add functionalities to their Laravel-based applications without needing to write them from scratch. Developers have the ability to create their own code packages for routine use or utilize ready-to-use packages.
- Complete authentication system
- Object-relational mapping – The Eloquent ORM included with Laravel uses classes in the database tables to allow for easier data access and manipulation.
- Automated testing
- Command-line interface with many pre-built commands
- Portable virtual development environment
What’s New and Improved in Laravel 8?
The latest release of the Laravel framework is Laravel 8. Originally released in late 2020, developers have had a bit of time to play with the new version and gather their thoughts on whether or not this release was worth the wait.
The new features of Laravel 8 include:
1. Laravel Jetstream
Jetstream comes “out of the box” with many helpful features such as login, registration, email verification, session tracking, two-factor authentication, and team management. When it comes to scaffolding, Jetstream offers 2 options: Inertia and Livewire.
2. Model Factory Classes and Models Directory
With the release of Laravel 8, eloquent model factories are now based on class. This helps give improved support for relationships between factories.
With this, devs have the ability to manage object states by using simple methods typically calling the state() method (given in the Laravel base factory class). This takes an argument as a function while taking in an array of attributes assigned to the factory.
The application skeleton of Laravel 8 includes an app/Models directory as well. While all generator commands assume that models exist, if the directory at hand doesn’t actually exist, the framework assumes the application keeps models within the app/ folder.
3. Removed the Namespace Prefix of Controllers
In earlier Laravel versions, developers had the ability to use a property called $namespace to automatically prefix the controller’s namespace by applying App/Http/Controllers. Laravel previously sometimes doubled the namespace prefixes when using callable syntax in the web.php route’s code.
4. Migration Squashing
For applications containing many different migration files, developers now have the ability to “squash” them into a single SQL file. When running migrations, this file is the first executed followed by any migration files remaining that aren’t a part of the squashed schema file. Squashing migration files like this helps decrease migration file bloat while improving testing performance.
5. Job Batching
This new release of Laravel also comes with a helpful feature that allows for devs to dispatch a group of jobs that are then executed in parallel with each other.
Devs can also monitor the progress of the batched or grouped jobs by using the then, catch, and finally methods to define their completion callbacks. All of the callback methods have access to the $batch object, which contains methods such as failure determination, batch cancellation, status checking, and more.
6. Maintenance Mode
In Laravel 7, the framework featured an “allow” list of IP addresses approved to use to access the application while in maintenance mode. To make things simpler, Laravel 8 now utilizes the “secret” solution where devs have the ability to specify the bypass token using the secret option.
While in maintenance mode, developers can access their application URLs while Laravel automatically passes the bypass cookie to the browser. After issuing the cookie, devs access the app as they would normally in non-maintenance mode.
To prevent users from accidentally using PHP artisan down during deployment, Laravel 8 also offers the option for rendering a maintenance mode view and returning whenever a request is made.
7. Improved Rate Limiting
This latest Laravel version improves the existing rate limiting functionality while still supporting backward compatibility with the existing throttle middleware. This offers the developers far more flexibility than previously possible.
These are just a few of the exciting and helpful new features released in Laravel 8. Between improved features for developers’ ease of use, more helpful migration and batching, as well as the new scaffolding feature, chances are that this framework will only continue to rank among the most used.