Read the full tutorial here:
Creating your First Symfony App and Adding Authentication
This application detailed the step by step guide on how to build your first Symfony application and add authentication to it using Auth0.
This demo uses:
To run the demo follow these steps:
- Running
git clone https://github.com/auth0-blog/symfony-authorization.git
- Run
composer install
to install all the project's dependencies. - If you do not have an Auth0 account, sign up for one now. Navigate to the Auth0 management dashboard, select Applications from the navigation menu, then select or create a regular web application that you want to connect with Symfony
- Create a
.env
file within the root folder of the project and include your Auth0 credentials as well as your proposed database details:
DATABASE_URL=mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7
Update this line with your own credentials and the name you want to use for the database, e.g. techcompanies
. If you don't have MySQL installed and set up on your system, follow this guide to get started.
- db_user: Replace with your database username
- db_password: Replace with your database password
- _db_name: Replace with your database name. You don't have to create the database yet, as we'll do that in the next step.
Next, add your Auth0 credentials:
AUTH0_CLIENT_ID=AUTH0_CLIENT_ID
AUTH0_CLIENT_SECRET=AUTH0_CLIENT_SECRET
AUTH0_DOMAIN=AUTH0_DOMAIN
- Next, run the following command to create a database with the value of your database name:
php bin/console doctrine:database:create
And this to create your database table:
php bin/console doctrine:schema:update --force
- Head over to your Auth0 dashboard and register Allowed Callback URLs as
http://127.0.0.1:8000/auth0/callback
and Allowed Logout URLs ashttp://127.0.0.1:8000/auth0/logout
respectively.
- Finally run the application with:
php bin/console server:run
- 🏠 Auth0 Blog
- 🚀 Symfony