https://github.com/hakobyansen/php-routing-attributes-example
An example app for DEV article
https://github.com/hakobyansen/php-routing-attributes-example
Last synced: about 1 year ago
JSON representation
An example app for DEV article
- Host: GitHub
- URL: https://github.com/hakobyansen/php-routing-attributes-example
- Owner: hakobyansen
- Created: 2024-03-10T05:34:55.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-12T19:37:32.000Z (over 2 years ago)
- Last Synced: 2025-01-22T16:48:22.987Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This is an example app for [DEV article](https://dev.to/hakobyansen/routing-implementation-using-php-attributes-n1l).
Create `.env` file in the root of the project with following single variable:
```
JSON_PLACEHOLDER_BASE_URL=https://jsonplaceholder.typicode.com
```
Build, run and install composer dependencies:
```shell
docker-compose up --build
```
Install composer dependencies
```shell
docker-compose run app composer install
```
Once you are up and running, you can retrieve existing user by ID or create new user using `curl` or another HTTP client.
```shell
# retrieve user by ID
curl -X GET --location "http://localhost:8080/users?id=10"
-H "Content-Type: application/json"
-H "Accept: application/json"
# create new user
curl -X POST --location "http://localhost:8080/users" \
-H "Content-Type: application/json" \
-d "{
\"name\": \"John Smith\"
}"
```