Laravel Basic Auth

Create a laravel 8 app with basic authentication

Paul
2 min readSep 7, 2021
Photo by Pierre Châtel-Innocenti on Unsplash

Laravel 8 has removed default auth scaffolding and simply provides a composer package for creating auth scaffold in a Laravel application. This article will show how to get a basic authentication system up and running with the laravel/ui package.

Create a new project

composer create-project --prefer-dist laravel/laravel laravel_demo

For more detailed installation instructions, visit the documentation.

Database configuration

You can set up a database like mysql by modifying the .envfile:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=db name
DB_USERNAME=db user name
DB_PASSWORD=db password

Or you can set up sqlite:

  • Create file called database.sqlite in this folder as database/database.sqlite
  • Modify the .env file like this:
DB_CONNECTION=sqlite

Note:

  • sqlite database doesn’t need the other database configurations
  • to modify the path/file name of the sqlite database file add in this config: DB_DATABASE=database\database.sqlite

Install Laravel UI

composer require laravel/ui

Install bootstrap auth scaffolding

php artisan ui bootstrap --auth

Install npm packages

npm installnpm run dev

Run the development server

php artisan serve --port=8000

Now you can see your project served on the following url in your browser: http://localhost:80000

registration page

You should now see ‘login’ and ‘Register’ buttons in the top right, and be able to register, login and logout of your application!

--

--

Paul
Paul

Written by Paul

I am a software developer and I like to write about interesting things I come across in my day to day.

No responses yet