Laravel 8.3 Released

News

September 16th, 2020

laravel8.jpg

The Laravel team released v8.3.0 this week with JSON casting for database test assertions, the ability to use closures in queued batches, and added various facade method PHPDocs.

New castAsJson() method for Database Assertions

Andrew Brown contributed a castAsJson() method to the base Laravel test case to help assert JSON in the database:

1$this->assertDatabaseHas('users', [
2 'name' => 'Peter Parker',
3 'email' => 'spidey@yahoo.com',
4 'skills' => $this->castAsJson(json_encode(['web slinging', 'spidey-sense', 'sticky feet'])),
5]);

Updated PHPDotEnv Version

Graham Campbell contributed an update to the PHPDotEnv version used in Laravel 8 to work around some reported issues upstream issues:

I am going to just patch phpdotenv 5.x to convert boolean values from $_ENV and $_SERVER to strings, instead of skipping over them as invalid. This should resolve this issue for people, without needing this hack.

Using a Closure in a Queued Batch

Mohamed Said contributed a feature that allows defining a closure in a queued batch:

Starting Laravel v8.3.0 (released today), you can include closures in a batch that's sent to the queue. It comes in handy when you want to perform simple tasks. pic.twitter.com/A9VY5rRjKb

— Mohamed Said (@themsaid) September 15, 2020

And here’s an example from the pull request:

1Bus::batch([
2 new ProcessPodcast,
3 function(){
4 // ...
5 },
6 new ReleasePodcast
7])->dispatch();

Updated PHPDocs for Facade Methods

@Adel contributed some missing PHPDocs for facade methods on the Log, Mail, Redirect, Route, URL, and Validator facades. These updates are quality-of-life improvements for those using IDEs that want auto-completion for facades.

Release Notes

You can see the full list of new features and updates below and the diff between 8.2.0 and 8.3.0 on GitHub. At the time of writing, an official changelog was not ready yet, but you can reference the future 8.x changelog updates on GitHub.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.