Hello, fellow creatures. This is System Team’s Eric again. For today’s blog, I’d like to write about the different authentication scaffoldings that we usually use most of the time for the systems we develop. I’m going to discuss two of these scaffolding packages and how we can customize it to our project’s specifications; Laravel/UI and Laravel/Jetstream.
Since the most recent blog written by our teammate, Fiona, is about Laravel Sanctum. We’re also gonna check on how Sanctum integrates with Jetstream.
Let’s start first with the more complex package, the Laravel Jetstream. Back then, we used to utilize the Laravel/UI but moving forward with new upcoming projects, this is the one we will be implementing on the system because Laravel/Jetstream is the more robust package when it comes to authentication there are a lot of features that Laravel/Jetstream has that Laravel/UI doesn’t.
To install Laravel/Jetstream;
1) Run a composer common in your terminal and type the following;
composer require laravel/jetstream
2) Once the package has been added completely to composer. You may now choose between livewire or inertia on what to use as your frontend stack. Once you have chosen, just run the following command:
php artisan jetstream:install {livewire / inertia}
Running this command should generate PHP class files related to Laravel Jetstream such as configs, migrations, and etc.
3) After installing Jetstream, install then build your NPM dependencies
npm install
npm run build
4) Then build your database
php artisan migrate
This is the last step and you’re good to go. You can now register and login users. The beauty of Laravel/Jetstream is that the package already comes with Laravel/sanctum so no need to setup separately. Unlike Laravel/UI that has no built-in API support. Hence, other developers has to use Laravel/Passport.
Now of the Laravel/UI package. This is a basic installation of the Laravel/UI package, this is the most basic scaffolding that we use for the simplest web applications. The package already includes the routes, controllers, views, and other classes that the authentication might need. Although this package has been removed from the official documentation for Laravel 10’s starter kits. We can still utilize this package for our projects. As of this writing, you can check the different starter kits for the authentication portion of your project here;
https://laravel.com/docs/10.x/starter-kits.
To install Laravel/UI package;
1) Run a composer command in your terminal and type the following;
composer require laravel/ui
2) After the command successfully executes. Like with Laravel/Jetstream. You may choose which of the following frontend stack would you be using to scaffold the frontend.
You can just choose one of the following commands;
// Generate basic scaffolding...
php artisan ui bootstrap
php artisan ui vue
php artisan ui react
// Generate login / registration scaffolding...
php artisan ui bootstrap --auth
php artisan ui vue --auth
php artisan ui react --auth
After running this command. That’s it! You already have a working authentication on your system unless you have something that needs to be customized inside the authentication process.
The only difference between the above and below codeblocks is that without the –auth option of the command. Laravel will not publish the necessary classes we need to customize the authentication process. Like for example, authentication using multiple guards.
In conclusion, if you’re planning on creating just a very simple website. Laravel/UI is enough to handle the authentication. But for more advanced sites that need more control over the system’s authentication, especially for single page applications, you might need to use Laravel/Jetstream. There are still more options out there like Laravel Breeze but these are just the two that we’ve been using for our project development.
We’re developing something similar. We have established an online exhibition system and are deploying it, utilizing this type of technology, and we do everything, from planning to infrastructure design, system development, and design. Please do not hesitate to contact us at info@commude.ph.
“Today we think ahead as one, in making tomorrow so much fun.”