Top 10 Key Features of Laravel 5.8

Page 1

New Features of Laravel 5.8

www.techtic.com | info@techtic.com


List of laravel 5.8 Features • Automatic Policy Resolution • Update Cache TTL • Support Carbon 2.0

• HasOneThrough Eloquent Relationship • Token Guard Token Hashing • Scheduler timezone Configuration • Artisan Call Improvements • Artisan Serve Improvements

• Mock Testing Helper Methods • Higher Order orWhere Eloquent Method www.techtic.com | info@techtic.com


Features of laravel 5.8 Automatic Policy Resolution First up on the agenda is automatic policy discovery. In past versions of Laravel, each time a policy class is generated, you'd need to visit our AuthServiceProvider to manually wire it up with the appropriate model. It's not the end of the world, but still nonetheless a bit tedious. Now in Laravel 5.8, as long as you follow the standard naming convention, this policy discovery happens automatically.

Update Cache TTL A small, but important breaking change in Laravel 5.8 is the switch from minutes to seconds for all cache TTLs. In your codebase, track down any reference to cache()>put(), cache()->remember(), or any other variants, and do the necessary math to convert the expiration date from minutes to seconds (multiply by 60).

www.techtic.com | info@techtic.com


Features of laravel 5.8 Support Carbon 2.0 Carbon is a package that extends PHP’s own DateTime class and makes working with dates and time very easy. Laravel 5.8 provides support for the 2.0 release of Carbon. Among the new features of Carbon 2.0 is the CarbonImmutable class and a new Date facade.

HasOneThrough Eloquent Relationship Previously to get a supplier’s account history, you will have to find the supplier then write something like: $supplier->account->accountHistory. Now you may use a hasOneThrough relationship to skip this step, accessing a supplier’s account history straight away like this: $history = $supplier->accountHistory through the account model www.techtic.com | info@techtic.com


Features of laravel 5.8 Token Guard Token Hashing There is a simpler token guard which provides basic API authentication and in Laravel 5.8 it now supports storing tokens as SHA-256 hashes. This provides greater security over storing plain-text tokens.

Scheduler timezone Configuration In previous releases, you have to repeat this for every scheduled task and this can quickly become cumbersome if you have many of them. In Laravel 5.8 you can just define a method called scheduledTimezone in your app/Console/kernel.php file and return your default timezone.

www.techtic.com | info@techtic.com


Features of laravel 5.8 Artisan Call Improvements Laravel allows you to make Artisan commands from your code using the Artisan::call method.

Artisan Serve Improvements A way to quickly serve your Laravel application is by running the command php artisan serve. In previous versions of Laravel this command will run your application in a default port of 8000 and if you attempt to serve another application with the same command, this would fail. Now in version 5.8 the servecommand will scan for available ports up to port 8009 so you can serve multiple applications at once.

www.techtic.com | info@techtic.com


Features of laravel 5.8 Mock Testing Helper Methods When preparing your tests, you'll need to mock a class, set an expectation, and then update the related instance in Laravel's service container with your mocked version. Laravel 5.8 now ships with two testing helpers to simplify this setup a good bit: $this->mock() and $this->spy().

Higher Order orWhere Eloquent Method Laravel 5.8 introduces a “higher order” orWhere method, so you don’t need to write the above closure anymore.

www.techtic.com | info@techtic.com


About Techtic Solutions Techtic Solutions, Inc. is one of the most trusted Laravel development company with 10+ years of web development experience. Our team of experienced Laravel developers are adept at building simple to the most complex website apps seamlessly using Laravel PHP frameworks. Our clients swear by the codes we write – they are simple, expressive and scalable. We help build sophisticated websites that help maximize ROI for your business. We leverage the robust features and dynamic functionality of Laravel to deliver superior experience to your customers.

Our Services: Custom Laravel Web Development Laravel CMS development Laravel Application Development Laravel Ecommerce Development Laravel Enterprise Solution

Laravel Customization Laravel Theme/Template Design Laravel Plugin Development Laravel REST API Development Laravel Support & Maintenance

www.techtic.com | info@techtic.com


Contact Us Visit us: https://www.techtic.com Email: info@techtic.com Phone: +1 201.793.8324


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.