Laracon US 2024: Laravel Cloud, Inertia v2, VS Code and Laravel 11 "Minor" Features

After watching the Laracon US live stream on YouTube last night, I compiled a "quick overview" of 4 BIG things Taylor Otwell introduced on stage, with screenshots and code examples I managed to capture.

So, not in the order Taylor presented them, but in the order of importance, in my opinion, let's go.


1. Laravel Cloud

After the Laravel core team expanded to 30+ people, we knew they were onto something BIG. So, here it is.

Backstory:

  • In 2014, they launched Laravel Forge: a tool to quickly provision new projects on your account on Digital Ocean, AWS, etc.
  • In 2019, they released Vapor: a tool for serverless deployment, but again, on your AWS account
  • Now, in 2024, they release Laravel Cloud, aiming to solve the need to have any external accounts: you will be able to deploy Laravel projects using only the official Laravel Cloud infrastructure!

As Taylor said, their aim was "From Local 'Hello World' to Hello Web with Real URL" in under 1 minute. They overdelivered: in the early preview, he demonstrated it could be done in 25 seconds.

Taylor showed how to create a new project, create a new database, and enable/configure queue workers with just a few clicks.

Here are a few screenshots I managed to capture from mobile from that early preview (sorry for the quality):

When: early access in Q4 2024.

Price: unknown yet.

Quoting the official homepage:

We're still in the process of finalizing all pricing, but compute starts at less than a penny an hour. Laravel Serverless Postgres starts at 4 cents per hour. With app and database hibernation, you only pay for what you use.

Also, here is one slide from yesterday:

So, we could compare that to Vercel all-in-one solution, and we'll see if this Cloud mission is gonna be as big. What do you think?


2. Visual Studio Code: Official Extension

Many developers use PhpStorm with Laravel Idea plugin as their Laravel IDE. But it's not free.

In Taylor's words, even more developers just want to try things out without paying anything.

So, they will release the official Laravel VS Code extension to speed up the process of writing Laravel code in that editor.

This is the only screenshot I managed to capture while being busy taking notes:

From the demonstration, it looked a lot like Laravel Idea, with auto-guess, auto-complete, and auto-fill in various places of the code, making many things clickable for easy navigation.

When: "later this fall" (quoting Taylor)

Price: Free (seems like it)


3. Inertia v2.0: 6 New Features

Just a few months ago, Taylor said on the podcast that Inertia was almost a feature-complete product.

Last night on stage, he quoted himself, saying, "Well, I think I was wrong about it".

He announced the upcoming Inertia 2, with 6 new features:

  1. Async requests: all requests are async by default, which is the fundamental thing for the features below
  2. Polling: manual or automatic
  3. WhenVisible: when you have some expensive element at the bottom, so it will be enabled only when you scroll down to it
  4. Infinite scrolling with whenVisible(): mergeable props
  5. Prefetching: loading some data before it is actually needed
  6. Deferred props: not evaluated on the initial page load but requested immediately after a page is loaded, automatically

This is a bad-quality screenshot, but you can see a few code snippets and read about Inertia v2 in a bit more structured way in this blog article by Pascal Baljet.

v2 When: "hope for early October" (quoting Taylor)


4. New Laravel 11 "Minor" Features

They will not wait for Laravel 12 in Spring to release these pretty big improvements to the framework:

Local Temporary URLs

Private file serving, which has only worked with cloud providers before.

Route::get('/files', function () {
$url = Storage::temporaryUrl(
'wallpaper.jpg', now()->addSeconds(5)
);
 
return "<a href='{$url}' target='blank'>{$url}</a>";
});

Container Attributes

Auto-resolving parameters in Constructor instead of defining the binding in the AppServiceProvider.

That will NOT work:

class DeployApplication
{
public function __construct(
string $githubToken
)
{
dd($githubToken);
}
}

It will throw an "Unresolvable dependency" error.

But they will release this syntax:

use Illuminate\Container\Attributes\Config;
 
class DeployApplication
{
public function __construct(
#[Config('services.github.token')]
string $githubToken
)
{
dd($githubToken);
}
}

In general, I see PHP 8 attributes more and more adopted in Laravel and Livewire codebases.

Eloquent chaperone()

Fixed N+1 Query Problem while loading "parent" records in the foreach loop.

Look at this code:

$users = User::with('posts')->get();
 
foreach ($users as $user)
{
foreach ($user->posts as $post)
{
dump($post->user->email);
}
}

It will cause an N+1 query problem.

But not if you define THIS in the relationship:

app/Models/User.php:

public function posts(): HasMany
{
return $this->hasMany(Post::class)->chaperone();
}

P.S. Weird method name, right? I googled the meaning:

Deferred Functions

You won't need to configure queue drivers anymore for some quick operations that need to happen after the request is finished.

Just use defer():

Route::get('/defer', function () {
// Some heavy operations that may take seconds
defer(fn () => Metrics::report());
 
return view('time');
});

"Flexible" Cache with Defer

One important improvement that uses defer() under the hood.

Imagine you have a heavy query cached for a minute/hour:

$values = Cache::remember('metrics', 60, function () {
// Some heavy Eloquent operation
return User::with(...)
->where(...)
->groupBy(...)
->orderBy(...)
->get();
});

It will execute quickly from the cache for most users, but for that one "unlucky" person who happens to be the first to load that query without cache, the user experience should be pretty terrible.

Introducing Cache::flexible():

$values = Cache::flexible('metrics', [5, 10], function () {
// Some heavy Eloquent operation
return User::with(...)
->where(...)
->groupBy(...)
->orderBy(...)
->get();
});

Notice: I forgot to take notes on what exactly those [5, 10] parameters mean. We'll figure it out when the feature is released.

This will defer the re-caching operation to the background without compromising the user experience. It's also more widely known as stale-while-revalidate principle.

Concurrency Facade

Simultaneously execute multiple operations across PHP processes:

$values = Concurrency::run([
fn () => Metrics::get(),
fn () => Metrics::get(),
fn () => Metrics::get(),
fn () => Metrics::get(),
fn () => Metrics::get(),
]);

Or defer them, like in the feature above.

$values = Concurrency::defer([
fn () => Metrics::get(),
fn () => Metrics::get(),
fn () => Metrics::get(),
fn () => Metrics::get(),
fn () => Metrics::get(),
]);

So... Pretty impressive list for a "minor" release, huh?

When: if I understood correctly, "beta" for the majority/all of those features should be launched NEXT WEEK.


One More Thing: Teaser for Laracon AU

In the final words of his talk, Taylor also mentioned one "extra" thing. Monitoring and debugging Laravel applications is a pretty important topic, so wait for the Laracon AU in November when he will talk about that, probably showing another new "secret project" around it.


So yeah, a quick recap. That live-stream video (currently unlisted) will be released on YouTube later after some editing.

What do you think? What feature is the most/least exciting to you?

avatar

Awesome! Thanks for compiling it (saw it on LinkedIn)

avatar
DevLegalClaimAssistant

for **Cache::flexible() ** if it will re-caching operation to the background without compromising the user experience then how this first user will get back the result back return

avatar

Not sure, to be honest, will test and write about it separately, when it's released.

avatar

The very first user, or cache warming request, will still be slow, as the cache is empty. The difference with remember is that once it expires, the next request won't be slow again, as it will return the previously cached value.

To give an example, with rembember with a ttl of 5 minutes, every 5 minutes there will be at least one unlucky user. With flexbile, only the very first user will be unlucky.

avatar

Was waiting for the official VSCode extension for Laravel/PHP, ... for a really really long time! Other VSCode extenssions for PHP seems buggy or outdated, so hope a lot from that one :) Can't wait to test!

🥳 1
avatar

Vs code users are very happy to hear this, I developed 2 extension for my self.

avatar

Any idea of the release date please ?

avatar

Currently there is no set release date. It should come in the next few months probably. But there is no guarantee yet :)

avatar
Loganathan Natarajan

Thank you for briefing

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 68 courses (1183 lessons, total 43 h 18 min)
  • 90 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord

Recent New Courses