Laravel 5.8: A New Era of PHP Development
The latest version of Laravel, 5.8, has been released with a plethora of exciting new features and improvements. This update is a continuous effort to enhance the framework, making it more efficient and user-friendly.
Automatic Policy Resolution
One of the significant updates in Laravel 5.8 is the automatic policy resolution. Policies are classes that organize authorization logic around a particular model or resource. In previous versions, policies needed to be registered manually in the AuthServiceProvider. However, with Laravel 5.8, you no longer need to register policies manually. The framework can auto-discover policies as long as the model and policy follow standard Laravel naming conventions.
Carbon 2.0 Support
Laravel 5.8 provides support for Carbon 2.0, a package that extends PHP’s DateTime class. Carbon 2.0 introduces a new immutable date class, CarbonImmutable, which allows for more flexible date manipulation. With this update, you can create a new date object without modifying the original date.
HasOneThrough Eloquent Relationship
Laravel 5.8 introduces a new eloquent relationship, HasOneThrough. This relationship enables you to access a model’s related data through another model. For example, if you have three models – Supplier, Account, and AccountHistory – you can access a supplier’s account history through the account model.
Token Guard Token Hashing
Laravel 5.8 improves token guard security by storing tokens as SHA-256 hashes. This provides an additional layer of protection against unauthorized access.
Cache TTL
In previous versions, caching was set in minutes. However, with Laravel 5.8, caching is now set in seconds, providing more precise control over cache expiration.
Scheduler Timezone Configuration
Laravel 5.8 allows you to define a default timezone for scheduled tasks. You can set the timezone in the app/Console/kernel.php file, and it will be applied to all scheduled tasks.
Artisan Call Improvements
Laravel 5.8 simplifies Artisan command calls by allowing you to pass options as a single string. This makes it easier to call Artisan commands from your code.
Artisan Serve Improvements
The serve command in Laravel 5.8 scans for available ports up to port 8009, enabling you to serve multiple applications simultaneously.
Mock Testing Helper Methods
Laravel 5.8 introduces a new mock testing helper method, which simplifies the process of mocking objects and binding them to the container.
Higher Order orWhere Eloquent Method
The higher order orWhere method in Laravel 5.8 enables you to combine scoped queries with or conditions without defining a closure.
Upgrade Guide
If you’re eager to upgrade your existing Laravel application to version 5.8, refer to the official upgrade guide for step-by-step instructions.
What’s Next?
With Laravel 5.8, you can take advantage of the latest features and improvements to build more efficient and scalable applications. Whether you’re a seasoned developer or just starting out, Laravel 5.8 has something to offer.