Laravel 8.3 Released
Published on by Paul Redmond
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:
$this->assertDatabaseHas('users', [ 'name' => 'Peter Parker', 'email' => 'spidey@yahoo.com', 'skills' => $this->castAsJson(json_encode(['web slinging', 'spidey-sense', 'sticky feet'])),]);
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:
Bus::batch([ new ProcessPodcast, function(){ // ... }, new ReleasePodcast])->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.