Laravel 8, Jetstream and learning Laravel

Laravel 8 is out today, along with the amazing new “Jetstream” authentication scaffolding that has been built.

So I’ve just worked through doing a quick install and had a poke around and it is incredible what you get out of the box now. But also, I have two issues with it. This isn’t really a rant, I do love it. Just observations and possible things that I think the core Laravel team should think about.

1. The barrier to entry is too high now

If you install Laravel + Jetstream (the Livewire version), you are now faced with this as your welcome template:

<x-app-layout>
    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            Dashboard
        </h2>
    </x-slot>

    <div class="py-12">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
            <div class="bg-white overflow-hidden shadow-xl sm:rounded-lg">
                <x-jet-welcome />
            </div>
        </div>
    </div>
</x-app-layout>

My first question was “How can I customise the welcome component? That <x-jet-welcome /> bit?

And so I spent half an hour tracking down the JetstreamServiceProvider.php which registers all the components using this method:

protected function registerComponent(string $component)
    {
        Blade::component('jetstream::components.'.$component, 'jet-'.$component);
    }

And what’s super-annoying about this is that:

a) Because the registerComponent() method dynamically prefixes the component name with 'jet-‘, you can’t search the code for the full component name and find where it’s registered

b) Even if you could, it wouldn’t help very much finding the component template

c) IDE’s can’t help you navigate from the usage of the component to the component file.

So anyone without a pretty good grasp of Blade components and how to dive around in the vendor directory to find stuff, is going to be a bit stuck!

And yes, if you publish the assets, which you need to do anyway to modify them, they become a but more easily available, but knowing that you need to publish assets is another thing you need to know.

I feel like if I came from basic PHP, or some other eco system into Laravel now, I’d get stuck pretty quickly. There’s a LOT of implied knowledge needed to get started.

That barrier to entry just got a whole heap higher!

2. There’s too much out of the box

I was on a live-streamed chat with some WordPress friends today about the benefits of looking into Laravel if you’re a WordPress developer.

And one thing I said was that so often with WordPress core and many plugins, I find myself with too much stuff and wanting to turn some of it off.

I really think that the out-of-the box Laravel Jetstream setup has too much turned on:

  • API tokens
  • Profile photos
  • 2FA
  • Account deleting

I LOVE that I could turn these on with a single-line-of-code change, but, perhaps with the exception of 2FA, should these really all be on by default? I’m really not sure they should, and my first step on many projects will be to turn some of these features off.

And, actually, as I write this, I’m trying and failing to find out if enabling/disabling these things IS a one-line change, and how to go about doing it!

UPDATE: config/jetstream.php has a features array that allows you to turn off profile pictures and the API bits:

    'features' => [
        Features::profilePhotos(),
        Features::api(),
        // Features::teams(),
    ],

I still think they should be off by default though!

In summary

As a slightly-experienced Laravel developer, this is all really exciting stuff, if a little enigmatic in places – how DOES this stuff work!?

But as someone who wants to introduce people to Laravel as a way to build cool stuff, I really feel like there are some issues here.

But who am I to say? Kudos to Taylor and the team for an awesome release.

I’m off to build something!

Leave a Reply

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