Add Uccello to a Laravel project
It is possible to add Uccello to an existing Laravel project (version >= 5.6).
Since Uccello has its own authentication interface, remember to backup the following files and readjust them if necessary:
resources/views/auth/login.blade.php
resources/views/auth/register.blade.php
resources/views/auth/passwords/email.blade.php
resources/views/auth/passwords/reset.blade.php
1. Install the Uccello library
You can install the uccello/uccello
dependency with composer.
If you are using a version of Laravel lower than 5.5, you will need to add the following code in the config/app.php
file:
Then execute the following command to extract all the files necessary for Uccello to work properly:
For Laravel >= 6.*, it is necessary to install laravel/ui for adding auth management:
Laravel 6.x :composer require laravel/ui:1.*
Laravel 7.x :composer require laravel/ui:2.*
Laravel 8.x :composer require laravel/ui:3.*
2. Add the middlewares
Open the file app/Http/Kernel.php
and add the following code to add the middlewares used by Uccello :
3. Configure the routes
Add the following code to the routes/web.php
file to automatically generate the route for to access Uccello.
This automatically detects whether the notion of multi domains is used or not and redirects the user to the last domain he visited.
If you want to access Uccello from your home page, just replace Route::get('/uccello', ...)
by Route::get('/', ...)
4. Configure the environment
Once the project is created you can configure the .env
file as explained in Laravel's official documentation.
This is an example. Put your own data into the .env
file.
If you do not want to use the notion of multi domains, you can add the following line into the .env
file:
5. Execute migrations
Once the database is configured, it is now possible to execute migrations to create the database structure used by Uccello.
6. Create an user
To easily create a new user, execute the following command:
7. Activate connection log
You can see last connections of a user in his detail page. To activate this functionality edit the file located at app/Http/Controllers/Auth/LoginController.php
and the following code:
8. It's ready!
If you would like to use PHP's built-in development server to serve your application, this command will start a local development server:
Now you can go to the home page of your site: http://localhost:8000. Once redirected to the login page, you can authenticate yourself with the credentials created at the step 6.
Last updated