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.shscript 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
[email protected]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 installin both the main project dir and theclientdir - In the project dir, ensure the directory
varis crated and is writable. - Ensure the directory
var/keysis created. - Generate your keys using OpenSSL from inside the
var/keysdirectory:openssl genrsa -out private.key 2048openssl rsa -in private.key -pubout -out public.key
- If necessary, make the
bin/consolescript executable:chmod +x bin/console - Run
bin/console doctrine:database:createto create the SQLite database. - Run
bin/console doctrine:schema:createto create the database tables. - Run
bin/console app:bootstrapto bootstrap the database with the demo data.- Run
bin/console app:bootstrap --helpfor more options. - Otherwise the default user is
[email protected]with passwordpassword.
- Run
- Run
symfony server:start -dto start the server in the background on port 8000. - From the
clientdirectory, runphp -S localhost:8080 app.phpto start the client on port 8080. - You may need to edit the
client/app.phpfile 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.