After creating your project with the composer in Laravel, mostly next step is to enable the authentication. It is very simple to enable the Laravel auth with PHP artisan command. The most simple commands to follow is as below
Adding SQLite Database to Laravel
First of all, you have to add the database into the ".env" file. The simplest database that you could use is the SQLite database with Laravel. You can create a simple SQLite file in the database folder and add the absolute path in the ".env" file.
>> touch database\database.sqlite
The above command is for creating the database file. You may use create the file manually if you are using windows.
You can change the .env file like this.
Enable Auth Middleware
Laravel's
laravel/uipackage provides a quick way to scaffold all of the routes and views you need for authentication using a few simple commands:
You can add this package with these commands
composer require laravel/ui "^1.0" --dev
php artisan ui vue --authNext, simply apply the migrations with the PHP Artisan command.
php artisan migrateNew Laravel Application with Auth
laravel new blog --authAuthenticated User Detail
use Illuminate\Support\Facades\Auth;
$user = Auth::user(); //If you want to get the ID of the use
$id = Auth::id(); //If you want to get the ID of the userLaravel Rollback Migrations
if in any case, you wish to undo your migrations you may use this simple command
>> php artisan migrate:reset
Comments
Post a Comment