PHPackages                             auth0-samples/laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. auth0-samples/laravel

ActiveProject[Framework](/categories/framework)

auth0-samples/laravel
=====================

Sample application demonstrating how to integrate Auth0 with Laravel 9 or Laravel 10 for session-based authentication and token-based authorization.

7.10.0(2y ago)4647855[2 PRs](https://github.com/auth0-samples/laravel/pulls)MITPHPPHP ^8.0CI failing

Since May 20Pushed 10mo ago30 watchersCompare

[ Source](https://github.com/auth0-samples/laravel)[ Packagist](https://packagist.org/packages/auth0-samples/laravel)[ RSS](/packages/auth0-samples-laravel/feed)WikiDiscussions 7.x Synced 3w ago

READMEChangelogDependenciesVersions (13)Used By (0)

[![Auth0 Laravel SDK](https://camo.githubusercontent.com/5cd2bdae557a87e2c38592d89ef76df9e06959d6727dd4e6e6f85c0ed8a2bb26/68747470733a2f2f63646e2e61757468302e636f6d2f776562736974652f73646b732f62616e6e6572732f6c61726176656c2d61757468302d62616e6e65722e706e67)](https://camo.githubusercontent.com/5cd2bdae557a87e2c38592d89ef76df9e06959d6727dd4e6e6f85c0ed8a2bb26/68747470733a2f2f63646e2e61757468302e636f6d2f776562736974652f73646b732f62616e6e6572732f6c61726176656c2d61757468302d62616e6e65722e706e67)

📚 [Documentation](#documentation) — :rocket: [Getting Started](#getting-started) — :round\_pushpin: [Routes](#demonstration-routes) — :wrench: [Default Changes](#changes-to-the-default-laravel-application)

This is a sample project demonstrating how to integrate [the Auth0 Laravel SDK](https://github.com/auth0/laravel-auth0) into a Laravel 9 application. For Laravel 10 applications, the integration steps are identical.

Documentation
-------------

[](#documentation)

Guidance on integrating Auth0 into your Laravel application can be found here:

- [Auth0 Laravel SDK Readme](https://github.com/auth0/laravel-auth0/blob/master/README.md)
- [Auth0 Laravel SDK Session Authentication Quickstart](https://auth0.com/docs/quickstart/webapp/laravel)
- [Auth0 Laravel SDK Token Authorization Quickstart](https://auth0.com/docs/quickstart/backend/laravel)

You may also find the following documentation from the SDK's GitHub repository useful:

- [docs/Configuration](https://github.com/auth0/laravel-auth0/blob/master/docs/Configuration.md)
- [docs/Events](https://github.com/auth0/laravel-auth0/blob/master/docs/Events.md)
- [docs/Installation](https://github.com/auth0/laravel-auth0/blob/master/docs/Installation.md)
- [docs/Management](https://github.com/auth0/laravel-auth0/blob/master/docs/Management.md)
- [docs/Users](https://github.com/auth0/laravel-auth0/blob/master/docs/Users.md)

Getting Started
---------------

[](#getting-started)

Use Composer's `create-project` command to clone this repository and install the dependencies:

```
composer create-project auth0-samples/laravel auth0-laravel-quickstart && cd auth0-laravel-quickstart
```

Authenticate with Auth0 using the bundled Auth0 CLI:

```
./auth0 login
```

> **Note**
> Authenticate as a "user" if prompted.

Create an Auth0 Application:

```
./auth0 apps create \
  --name "My Laravel Backend" \
  --type "regular" \
  --auth-method "post" \
  --callbacks "http://localhost:8000/callback" \
  --logout-urls "http://localhost:8000" \
  --reveal-secrets \
  --no-input \
  --json > .auth0.app.json
```

Create an Auth0 API:

```
./auth0 apis create \
  --name "My Laravel Backend API" \
  --identifier "https://github.com/auth0/laravel-auth0" \
  --offline-access \
  --no-input \
  --json > .auth0.api.json
```

Run the application:

```
php artisan serve

```

Demonstration Routes
--------------------

[](#demonstration-routes)

This sample includes a few demonstration routes to help you get started.

### Session-Based Authentication

[](#session-based-authentication)

The SDK automatically registers the following routes for session-based authentication:

MethodRouteDescriptionGET[/login](https://localhost:8000/login)Starts the user authentication flow. Sets up some initial cookies, and redirects to Auth0 to authenticate.GET[/callback](https://localhost:8000/callback)Handles the return callback from Auth0. Completes setting up the user's Laravel session.GET[/logout](https://localhost:8000/logout)Logs the user out.The `routes/web.php` file contains routes that demonstrate working with session-based authentication. These are:

MethodRouteDescriptionGET[/private](https://localhost:8000/private)Demonstrates how to protect a route with the `auth` middleware.GET[/scope](https://localhost:8000/scope)Demonstrates how to protect a route with the `can` middleware.GET[/colors](https://localhost:8000/colors)Demonstrates how to make Management API calls.### Token-Based Authorization

[](#token-based-authorization)

The `routes/api.php` file contains routes that demonstrate token-based authorization. These are:

MethodRouteDescriptionGET[/api](https://localhost:8000/api)Demonstrates how to extract information from the request token.GET[/api/private](https://localhost:8000/api/private)Demonstrates how to protect an API route with the `auth` middleware.GET[/api/scope](https://localhost:8000/api/scope)Demonstrates how to protect an API route with the `can` middleware.GET[/api/me](https://localhost:8000/api/me)Demonstrates how to make Management API calls.Changes to the Default Laravel Application
------------------------------------------

[](#changes-to-the-default-laravel-application)

This sample is based on [the default Laravel application](https://github.com/laravel/laravel) you can [create](https://laravel.com/docs/9.x/installation#your-first-laravel-project) using `laravel new` or `composer create-project`.

> **Note**
> For Laravel 10, use `composer create-project laravel/laravel:^10.0` and follow the same steps outlined below.

Few changes are necessary to get started, as the SDK automatically sets up all the necessary guards, middleware and other services necessary to support authentication and authorization. The following is a list of changes that have been applied:

- The `auth0/login` package has been added to the `composer.json` file, using:

    ```
    composer require auth0/login:^7.8 --update-with-all-dependencies
    ```
- The `config/auth0.php` file was generated, using:

    ```
    php artisan vendor:publish --tag auth0
    ```
- The `routes/web.php` file was updated to include the demonstration routes.
- The `routes/api.php` file was updated to include the demonstration routes.

Feedback
--------

[](#feedback)

We appreciate your feedback! Please create an issue in this repository or reach out to us on [Community](https://community.auth0.com/).

Vulnerability Reporting
-----------------------

[](#vulnerability-reporting)

Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues.

What is Auth0?
--------------

[](#what-is-auth0)

Auth0 helps you to easily:

- implement authentication with multiple identity providers, including social (e.g., Google, Facebook, Microsoft, LinkedIn, GitHub, Twitter, etc), or enterprise (e.g., Windows Azure AD, Google Apps, Active Directory, ADFS, SAML, etc.)
- log in users with username/password databases, passwordless, or multi-factor authentication
- link multiple user accounts together
- generate signed JSON Web Tokens to authorize your API calls and flow the user identity securely
- access demographics and analytics detailing how, when, and where users are logging in
- enrich user profiles from other data sources using customizable JavaScript rules

[Why Auth0?](https://auth0.com/why-auth0)

License
-------

[](#license)

This project is licensed under the MIT license. See the [LICENSE](./LICENSE) file for more info.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community30

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~26 days

Recently: every ~51 days

Total

11

Last Release

867d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ec0ec745d1cdbff1167fbb891d9d5985eaac4378150ca443fcc67a6ef8350382?d=identicon)[Auth0](/maintainers/Auth0)

---

Top Contributors

[![evansims](https://avatars.githubusercontent.com/u/3093?v=4)](https://github.com/evansims "evansims (53 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (49 commits)")[![joshcanhelp](https://avatars.githubusercontent.com/u/855223?v=4)](https://github.com/joshcanhelp "joshcanhelp (18 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (17 commits)")[![alexisluque](https://avatars.githubusercontent.com/u/30907012?v=4)](https://github.com/alexisluque "alexisluque (9 commits)")[![chenkie](https://avatars.githubusercontent.com/u/1847678?v=4)](https://github.com/chenkie "chenkie (8 commits)")[![cocojoe](https://avatars.githubusercontent.com/u/928115?v=4)](https://github.com/cocojoe "cocojoe (6 commits)")[![aaguiarz](https://avatars.githubusercontent.com/u/1636576?v=4)](https://github.com/aaguiarz "aaguiarz (5 commits)")[![glena](https://avatars.githubusercontent.com/u/5647310?v=4)](https://github.com/glena "glena (5 commits)")[![lbalmaceda](https://avatars.githubusercontent.com/u/3900123?v=4)](https://github.com/lbalmaceda "lbalmaceda (3 commits)")[![paulioceano](https://avatars.githubusercontent.com/u/15818783?v=4)](https://github.com/paulioceano "paulioceano (3 commits)")[![james-flynn-ie](https://avatars.githubusercontent.com/u/29207704?v=4)](https://github.com/james-flynn-ie "james-flynn-ie (3 commits)")[![Widcket](https://avatars.githubusercontent.com/u/5055789?v=4)](https://github.com/Widcket "Widcket (2 commits)")[![iannyanes](https://avatars.githubusercontent.com/u/2512171?v=4)](https://github.com/iannyanes "iannyanes (2 commits)")[![vmartynets](https://avatars.githubusercontent.com/u/1114365?v=4)](https://github.com/vmartynets "vmartynets (1 commits)")[![Annyv2](https://avatars.githubusercontent.com/u/5016479?v=4)](https://github.com/Annyv2 "Annyv2 (1 commits)")[![crew-security](https://avatars.githubusercontent.com/u/25953410?v=4)](https://github.com/crew-security "crew-security (1 commits)")[![jimmyjames](https://avatars.githubusercontent.com/u/276225?v=4)](https://github.com/jimmyjames "jimmyjames (1 commits)")[![albertoperdomo](https://avatars.githubusercontent.com/u/24216?v=4)](https://github.com/albertoperdomo "albertoperdomo (1 commits)")[![JoshSalway](https://avatars.githubusercontent.com/u/1491451?v=4)](https://github.com/JoshSalway "JoshSalway (1 commits)")

---

Tags

auth0authorizationdx-sdk-quickstartlaravelphpquickstartwebappjwtapiframeworklaravelJWKauthAuthenticationJSON Web TokenoauthauthorizationsecureprotectOpenIdloginauth0json web key

### Embed Badge

![Health badge](/badges/auth0-samples-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/auth0-samples-laravel/health.svg)](https://phpackages.com/packages/auth0-samples-laravel)
```

###  Alternatives

[auth0/login

Auth0 Laravel SDK. Straight-forward and tested methods for implementing authentication, and accessing Auth0's Management API endpoints.

2745.2M3](/packages/auth0-login)[auth0/auth0-php

PHP SDK for Auth0 Authentication and Management APIs.

40921.3M85](/packages/auth0-auth0-php)[auth0/symfony

Symfony SDK for Auth0 Authentication and Management APIs.

128790.7k](/packages/auth0-symfony)[auth0/wordpress

WordPress Plugin for Auth0

18122.7k](/packages/auth0-wordpress)[league/oauth2-server

A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.

6.7k143.0M272](/packages/league-oauth2-server)[chervand/yii2-oauth2-server

OAuth 2.0 server for Yii 2.0 with MAC tokens support.

1524.5k1](/packages/chervand-yii2-oauth2-server)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
