Laracon 2024: Taylor Otwell: Laravel Keynote

Taylor’s keynote is always the highlight of the conference, and this year was no exception.

Here’s the video; below are a few of the highlights and what I like about them.

First-Party VS Code Extension

Coming later this fall is a new VS Code Extension developed and maintained by Laravel.

It will offer autocomplete for a number of features (config and env values, app services, translations, views, Inertia props, and Eloquent), along with click-through links and preview-on-hover.

Probably my favorite feature is the Test Explorer integration: whether you’re using PHPUnit or Pest, your tests will show up in the sidebar, where you can run and see the status; you can also see test failure details in a “peek” UI widget.

This sounds like it will replace several of the extensions I currently use, and I’m excited to have first-party support for Laravel development in VS Code.

Container Attributes

A Container Attributes feature feels like dependency injection for config values or other attributes. This doesn’t seem like a huge feature, but will reduce some boilerplate code.

Chaperone Method

The just-released ->chaperone() method helps prevent n+1 queries when you need to do something like retrieve authors with their posts and then access something on the author model for each post.

I know I’ve run into this before, doing something like this to prevent the n+1 queries: $authors->with('posts.author');

defer() helper and Cache::flexible()

This looks very promising. It’s a simple way to push some work to the background, running it after the server has responded to the incoming request. I can immediately think of several apps where I have a super-simple job just to run something asynchronously after a request, and this can replace those.

Some potential use cases are for sending analytics, notifying third-party services, or any other “fire-and-forget” interaction.

This also enables a new Cache::flexible() method, providing a stale-while-revalidate mechanism to reduce the number of requests that hit a cold cache.

You provide two TTL numbers to this method:

  • The standard TTL indicating how long the cached value is valid
  • A second TTL indicating how long it’s acceptable to provide the stale value, while refreshing the value in the background so it’s ready for the next request

I’m very excited for this, as it will help improve several pain points in a couple of current applications.

Concurrency Facade

If some code needs to run multiple slow processes that don’t depend on each other, the new Concurrency facade will be helpful.

Concurrency::run([]) can be used to run multiple requests/jobs/etc. in parallel, returning the values for subsequent use; or Concurrency::defer([]) can run multiple processes in parallel after the current request, using the new defer() helper.

Inertia 2.0

Most of my apps are Livewire, but these features look amazing and I’ll definitely be using them:

  • Async requests: currently, Inertia runs only one request at a time; this allows multiple requests
  • Polling: I’ve manually written polling in several different components, and this will simplify and standardize those
  • WhenVisible: this will wait to load props until the user scrolls to a portion of the page that needs them, and then it loads each prop as it needs. I’ve almost written some code to do this, but it seemed too complex for the benefit, so found another solution instead. Having this available as a first-party solution will add definite performance improvements.
  • Infinite scrolling: not anything I’ve needed yet, but might be useful at some point
  • Prefetching: this stands to improve performance by optimistically loading data so it’s ready as soon as a user visits another page
  • Deferred props: another strategy for improving performance by waiting to load specific props until after the initial page has been rendered

Laravel Cloud

The big announcement: Laravel Cloud is a fully-managed infrastructure platform built specifically for hosting Laravel apps as simply as possible.

Taylor demonstrated the process of adding a new application, providing a repository, and deploying, all within 25 seconds!

It provides scalability both up and down; when not in use, it can be set to hibernate to save costs.

It allows you to create deployments from different branches, enabling an easy way to preview code in different branches before going live. (This is maybe my favorite feature.)

In the talk, he mentioned PostgreSQL as a serverless database option; later in a podcast interview with Matt Stauffer, he mentioned that MySQL is in the works for launch, but wasn’t quite complete in time for the talk.

Laravel Cloud will support creating multiple worker instances (separate from web instances) for handling queues.

It will provide SSL certificates and firewall using Cloudflare. He didn’t mention it in the talk, but in the podcast he did mention that Laravel Cloud runs on AWS, and another conference attendee said that Taylor told him it used Kubernetes.

Costs and Features

For sandbox:

  • No monthly fee
  • Compute: less than 1¢ per hour
  • Serverless Postgres: from 4¢ per hour plus 75¢ per GB
  • laravel.cloud domains included free

For production:

  • Costs not announced
  • Auto-scaling compute
  • Larger instance sizes
  • Custom domains included

Observability and debugging: wait until Laracon Australia!

Overall, Laravel Cloud seems like it dramatically lowers the barrier to entry for new developers, side projects, or anyone or any project that just wants to get something up and running with a low barrier to entry. I’m excited to see how this is going to change the ecosystem, as it makes it easier for people to focus on just building and shipping software.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.