This is the sample app accompanying my blog post at https://davegebler.com/post/php/build-oauth2-server-php-symfony
- Clone this repo
- Ensure you have Docker Engine >= 17.05 installed. https://docs.docker.com/get-docker/
- Run
docker compose up -d
- Run the included
setup.sh
script to install dependencies and create the database. - Visit http://localhost:8080 in your browser and click the single sign-on link to see the app in action.
- The username is
me@davegebler.com
and the password ispassword
- The username is
- Ensure you have PHP >= 8.1 installed, as well as the Symfony CLI, Composer and OpenSSL.
- Clone the repo
- Run
composer install
in both the main project dir and theclient
dir - In the project dir, ensure the directory
var
is crated and is writable. - Ensure the directory
var/keys
is created. - Generate your keys using OpenSSL from inside the
var/keys
directory:openssl genrsa -out private.key 2048
openssl rsa -in private.key -pubout -out public.key
- If necessary, make the
bin/console
script executable:chmod +x bin/console
- Run
bin/console doctrine:database:create
to create the SQLite database. - Run
bin/console doctrine:schema:create
to create the database tables. - Run
bin/console app:bootstrap
to bootstrap the database with the demo data.- Run
bin/console app:bootstrap --help
for more options. - Otherwise the default user is
me@davegebler.com
with passwordpassword
.
- Run
- Run
symfony server:start -d
to start the server in the background on port 8000. - From the
client
directory, runphp -S localhost:8080 app.php
to start the client on port 8080. - You may need to edit the
client/app.php
file to change the URI variables to match the URL and port of your local server.- For example, your Symfony server may use https://localhost:8000 instead of http://localhost:8000.
- Visit http://localhost:8080 in your browser and click the single sign-on link to see the app in action.