This is a tutorial on how to run an example laravel application that uses auth0 for authentication, we have it in two flavor, as a local application using apache, or in the cloud using heroku
git clone https://github.com/auth0/laravel-auth0-sample.git
Download composer and execute
php composer.phar install
If you want to use mysql
for the example, change settings in .env
file. The default settings are:
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
if you want to use another driver, modify config/database.php
directly.
After the database is configured, apply the migrations
php artisan migrate
Use php artisan key:generate
to generate your APP_KEY
.
-
Rename the
.env.example
file to.env
and populate it with your Auth0 credentials, including your client ID, client secret, and domain -
Go to your Auth0 dashboard and add
http://<ip-to-apache>/auth0/callback
to your authorized callbacks -
Run
php artisan serve
and browse to http://localhost:8000
In order to do this you need to have an heroku account and the Heroku toolbelt installed.
Login to heroku
heroku login
Next, we need to create an application from the local git repository. In your path to the repo execute
heroku create --buildpack https://github.com/heroku/heroku-buildpack-php#beta
Now you have a remote called heroku and you can upload to it by executing
git push heroku master
Heroku uses postgresql by default, we can enable it by executing
heroku addons:add heroku-postgresql:dev
Then apply the migrations by running the following command
heroku run php /app/artisan migrate
Add auth0 as an addon
heroku addons:add auth0 --type=php --subdomain=<your-domain>
Open your auth0 dashboard (you can use heroku addons:open auth0
) and configure the callback of your application to be
http://<domain>/auth0/callback
Configure heroku to use the same callback
heroku config:set AUTH0_CALLBACK_URL="http://<domain>/auth0/callback"
- The Procfile tells heroku how to invoke an apache instance that is compatible with laravel
- The
bootstrap/start.php
has a function that detects whether the enviroment is local or heroku
If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.
This project is licensed under the MIT license. See the LICENSE file for more info.