diff --git a/.setup/Dockerfile b/.setup/Dockerfile new file mode 100644 index 0000000..3a97b5a --- /dev/null +++ b/.setup/Dockerfile @@ -0,0 +1,9 @@ +FROM php:8.0-fpm-alpine + +COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer + +WORKDIR /var/www/html + +COPY . /var/www/html + +RUN composer install --optimize-autoloader --no-interaction diff --git a/.setup/site.conf b/.setup/site.conf new file mode 100644 index 0000000..a0d9fe3 --- /dev/null +++ b/.setup/site.conf @@ -0,0 +1,17 @@ +server { + index index.php index.html; + server_name php-docker.local; + error_log /var/log/nginx/error.log; + access_log /var/log/nginx/access.log; + root /var/www/html; + + location ~ \.php$ { + try_files $uri =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php:9000; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + } +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..c3b5697 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# Basic API + +A Basic API made with PHP without any Framework + +## Uses + +- PHP 8.0 +- PHP League - Container +- PHP League - Route +- Laminas Diactoros +- PHPUnit + +## How to Run + +To execute this project can be made two ways. + +Without `docker-compose`: + +```bash +composer install +php -S localhost:8080 +``` + +With `docker-compose`: + +```bash +docker-compose up -d +``` + +## Security + +If you discover any security related issues, please email vitorhugo.ro10@gmail.com instead of using the issue tracker. + +## Credits + +- [Vitor Merencio](https://github.com/vitorhugoro1) + +## License + +The GNU GENERAL PUBLIC LICENSE (GNU). Please see [License File](LICENSE.md) for more information. diff --git a/composer.json b/composer.json index b2b4d17..d91296f 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,6 @@ { "require": { + "php": "^8.0", "league/container": "^4.1", "league/route": "^5.1", "laminas/laminas-diactoros": "^2.6", diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..951c661 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +version: "3.7" + +services: + app: + image: nginx:latest + ports: + - 8080:80 + volumes: + - ./:/var/www/html + - ./.setup/site.conf:/etc/nginx/conf.d/default.conf + links: + - php + php: + build: + context: . + dockerfile: .setup/Dockerfile + volumes: + - ./:/var/www/html