UPDATE – 6/10/2020
This article was written before the Jetstream Drama over the weekend and it’s worth clarifying a few things, and saying what I’ve learned from the drama.
- I really hope I didn’t contribute any hate. That’s really NOT my intention. I’ve tried to say that I think Laravel and Jetstream are amazing things and Taylor has my utmost respect and thanks. My comments are meant to be entirely constructive. And I’ve presented small, concrete things that I think could improve first-time experience with Jetstream for some audiences.
- I come at this from the point of view of someone who’s far from a Laravel expert – I’m really still learning. But that’s part of my point: for someone in my position, Jetstream feels a bit inaccessible.
- Taylor Otwell (the creator of Laravel) has clarified that he made Jetstream as the kind of thing that HE would use. So in some ways, any critique of it from a less-experienced Laravel developer’s perspective (which is what this article presents) isn’t valid. Is it fair to say that it seems this is not a tool intended for beginners with the framework?
- However, I feel that with a few small changes and some additions to the documentation, it could be made more accessible for beginners and this would be a good thing for everyone.
- Yes, I should have read more of the docs before diving in. But Jetstream seems too inviting, I dived in headfirst and so got stuck. That’s a lesson for me.
- It’s because I think Laravel and Jetstream are awesome that I’d love them to be more accessible to more developers. Jetstream is actually a really good example of a set of components and classes at work, and it could serve as some easily explorable code demonstrating good practices. Auth scaffolding is like the “Hello world” of Laravel and I’d love for it to be as easy for the first time Laravel dev to explore as it is for the experienced one.
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 could be thought about for the future.
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, but it would at least leave you able to search for the component name and find something!
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!
Unless they notice that you can publish the components (if you know what that means), which you need to do to modify them. Sure, you can find out about publishing the components by reading the Jetstream docs. But I was keen to dive in and thought it would be easy to see how to edit what is effectively the “Hello world” page.
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: Tailwind; Blade Components; Livewire/Inertia.
That barrier to entry just got a whole heap higher!
2. There’s too much out of the box
[Note: Taylor took note of people’s feedback on this and has disabled the API and profile photos by default as of version 1.3.2!]
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.
This is easy enough to do: the config/jetstream.php
file has a features array that allows you to turn off profile pictures and the API bits:
'features' => [
Features::profilePhotos(),
Features::api(),
// Features::teams(),
],
But I still think they should be off by default!
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!