Simple example of an API REST with Symfony 5.2
PHP7.4 + MYSQL
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar install or composer install
$ cp .env.dist .env
Setup your database credentials in the env file
php bin/console doctrine:migrations:migrate
php bin/console doctrine:fixtures:load
visit https://localhost/doc for the documentation endpoint
$ curl -H 'content-type: application/json' -v -X GET http://127.0.0.1:8000/api/expenses
$ curl -H 'content-type: application/json' -v -X GET http://127.0.0.1:8000/api/expenses/:id
$ curl -H 'content-type: application/json' -v -X POST -d '{"description":"Foo bar","value":"19.99"}' http://127.0.0.1:8000/api/expenses
$ curl -H 'content-type: application/json' -v -X PUT -d '{"description":"Foo bar","value":"19.99"}' http://127.0.0.1:8000/api/expenses/:id
$ curl -H 'content-type: application/json' -v -X DELETE http://127.0.0.1:8000/api/expenses/remove/:id
For testing use admin:admin
$ curl -H 'content-type: application/json' -v -X GET http://127.0.0.1:8000/api/expenses -H 'Authorization:Basic username:password or email:password'
$ phpunit or ./bin/phpunit