Laravel Basic Auth

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!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store