https://github.com/lfsc09/itrade-api
API to serve data for itrade-dongs.
https://github.com/lfsc09/itrade-api
mysql php8 rest-api slim3
Last synced: 8 months ago
JSON representation
API to serve data for itrade-dongs.
- Host: GitHub
- URL: https://github.com/lfsc09/itrade-api
- Owner: lfsc09
- License: apache-2.0
- Created: 2022-06-18T02:36:39.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-09-10T18:47:19.000Z (almost 2 years ago)
- Last Synced: 2024-09-10T21:05:01.066Z (almost 2 years ago)
- Topics: mysql, php8, rest-api, slim3
- Language: PHP
- Homepage: https://api.itrade-dongs.com.br (Down)
- Size: 107 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/lfsc09/itrade-api/blob/main/LICENSE)

[](https://github.com/TrafeX/docker-php-nginx)

## Generate config file for Slim
Generate the **config.php** from _config.example.php_:
```php
putenv('DISPLAY_ERRORS_DETAILS='. TRUE);
putenv('DB_HOSTNAME=localhost');
putenv('DB_PORT=3306');
putenv('DB_USER=root');
putenv('DB_PASS=%PASSWORD%');
putenv('DB_NAME=u631028490_itrade');
putenv('JWT_SECRET_KEY=%ENCRYPTION_KEY_512%');
putenv('JWT_SECURE=' . FALSE);
```
> If you change the DB user password, also update it on `docker-conf/mysql/init/add-user.sql`.
> To use `JWT_SECURE` as `TRUE`, the Webserver container `Dockerfile` must be changed to listen for `ssl` connections. Also the `fullchain.pem` and `privkey.pem` must be provided to the container.
>
> https://github.com/TrafeX/docker-php-nginx/blob/master/docs/enable-https.md
## Deploy
> Make sure you did the step above before running the `compose up`.
It uses (https://github.com/TrafeX/docker-php-nginx) docker image for PHP-fpm with Nginx.
```bash
docker compose up -d
```
### Local Testing
#### In Windows
> https://stackoverflow.com/questions/8652948/using-port-number-in-windows-host-file
Setting up the api url dns, for locally testing with front-end.
In the `hosts` file of Windows.
```properties
127.x.x.x api.itrade-dongs.com.br
```
```bash
netsh interface portproxy add v4tov4 listenport=80 listenaddress=127.x.x.x connectport=8001 connectaddress=192.168.0.4
```
You can test the choosen local IPv4 address with
```bash
netstat -a -n -p TCP | grep "LISTENING"
```
Show the proxy maps with
```bash
netsh interface portproxy show v4tov4
```