Step By Step Tutorial On How To Use Auth0 in Laravel 9 for User Authentication

Mark Caggiano
3 min readMar 22, 2023

Step 1: Create a new Laravel project

Assuming you have Laravel installed, you can create a new project using the following command:

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

Step 2: Install the Auth0 PHP SDK

You can install the Auth0 PHP SDK using composer. Run the following command in the terminal:

composer require auth0/auth0-php

Step 3: Create an account and application in Auth0

You will need an Auth0 account to use their authentication service. Once you have an account, you can create a new application by following these steps:

  • Login to your Auth0 dashboard
  • Click on the “Applications” tab
  • Click the “Create Application” button
  • Choose “Regular Web Applications”
  • Enter a name for your application
  • Click the “Create” button

Step 4: Configure Auth0

After creating an application, you need to configure it by setting the callback URL and allowed logout URL. Follow these steps:

Step 5: Set up the Laravel Authentication

Laravel provides a built-in authentication system that can be used with third-party authentication providers like Auth0. Follow these steps:

  • Run the following command in the terminal to create the authentication scaffolding:
composer require laravel/ui

# for vue
php artisan ui vue --auth

# for bootstrap/vanilla
php artisan ui bootstrap --auth

# for react
php artisan ui react --auth

# Create users in database
php artisan migrate
  • Update your .env file with the Auth0…

--

--