Skip to content

Commit

Permalink
Merge pull request #2 from MrHDOLEK/#1-init-repo
Browse files Browse the repository at this point in the history
#1 - init repo
  • Loading branch information
MrHDOLEK committed Oct 19, 2023
2 parents f4d2459 + b7daba2 commit 7d32310
Show file tree
Hide file tree
Showing 72 changed files with 9,397 additions and 1 deletion.
1 change: 1 addition & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
json_path: coveralls-upload.json
53 changes: 53 additions & 0 deletions .docker/nginx/dev/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
user nginx;
worker_processes auto;

error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;

events {
worker_connections 4096;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

server {
index index.php index.html;

root /var/www/public;

# Redirection for the .html or similar cases
location / {
try_files $uri $uri/ /index.php$is_args$args;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param ORIG_PATH_TRANSLATED $document_root$fastcgi_script_name;
fastcgi_pass php:9000;
fastcgi_buffer_size 16k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 4064k;
fastcgi_max_temp_file_size 0;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_read_timeout 600s;
}
}
}
53 changes: 53 additions & 0 deletions .docker/nginx/prod/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
worker_processes auto;

error_log /proc/self/fd/2 info;
pid /var/run/nginx.pid;

events {
worker_connections 4096;
multi_accept on;
use epoll;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /proc/self/fd/1 main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 0;

gzip on;

server {
index index.php index.html;

root /var/www/public;

client_max_body_size 108M;

# Redirection for the .html or similar cases
location / {
try_files $uri $uri/ /index.php$is_args$args;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param ORIG_PATH_TRANSLATED $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_buffer_size 16k;
fastcgi_buffers 256 16k;
fastcgi_index index.php;
include fastcgi_params;
}
}
}
46 changes: 46 additions & 0 deletions .docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
ARG PHP_VERSION=8.2

FROM php:${PHP_VERSION}-fpm-buster

ARG COMPOSER_VERSION=2.5.7

ENV COMPOSER_MEMORY_LIMIT=-1

ARG INSTALL_COMPOSER_DEV=false

RUN useradd nginx && usermod -u 1001 www-data && groupmod -g 1001 www-data

RUN apt-get update && apt-get install -y nginx \
git zip bzip2 libpng-dev libpng-dev libicu-dev \
vim libjpeg62-turbo-dev libfreetype6-dev libonig-dev \
libpq-dev libxpm-dev libvpx-dev libbz2-dev zlib1g-dev libzip-dev gnumeric \
&& curl -sS https://getcomposer.org/installer | php -- --version="${COMPOSER_VERSION}" --install-dir=/usr/local/bin --filename=composer \
&& docker-php-ext-install intl bcmath mbstring bz2 gd zip opcache pcntl \
&& docker-php-ext-enable intl pcntl \
&& apt-get autoclean \
&& apt-get autoremove

COPY ./.docker/php/bin/entrypoint.sh /etc/entrypoint.sh
COPY ./.docker/nginx/prod/nginx.conf /etc/nginx/nginx.conf
COPY ./.docker/php/conf/php.ini /usr/local/etc/php/conf.d/php.ini
COPY ./.docker/php/conf/php-fpm.conf /etc/php/fpm/php-fpm.conf

RUN chmod +x /etc/entrypoint.sh

WORKDIR /var/www

COPY --chown=www-data:www-data . /var/www

RUN find /var/www -type d -exec chmod -R 555 {} \; \
&& find /var/www -type f -exec chmod -R 444 {} \;


RUN if [ ${INSTALL_COMPOSER_DEV} = true ]; then \
composer install --optimize-autoloader \
;else \
composer install --optimize-autoloader --prefer-dist --no-dev -o \
;fi

EXPOSE 80

ENTRYPOINT ["/etc/entrypoint.sh"]
31 changes: 31 additions & 0 deletions .docker/php/Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
ARG PHP_VERSION=8.2

FROM php:${PHP_VERSION}-fpm-buster

ARG COMPOSER_VERSION=2.5.7

ENV COMPOSER_MEMORY_LIMIT=-1

RUN apt-get update && apt-get install -y \
git zip bzip2 libpng-dev libpng-dev libicu-dev \
vim libjpeg62-turbo-dev libfreetype6-dev libonig-dev \
libpq-dev libxpm-dev libvpx-dev libbz2-dev zlib1g-dev libzip-dev gnumeric \
&& curl -sS https://getcomposer.org/installer | php -- --version="${COMPOSER_VERSION}" --install-dir=/usr/local/bin --filename=composer

RUN docker-php-ext-install intl bcmath mbstring bz2 gd zip pgsql pdo_pgsql opcache pcntl

RUN docker-php-ext-enable intl pcntl

RUN if [ ${INSTALL_XDEBUG} = true ]; then \
pecl install xdebug-${XDEBUG_VERSION} \
&& docker-php-ext-enable xdebug \
;fi

RUN usermod -u 1000 www-data

COPY ./.docker/php/conf/php-fpm.conf /usr/local/etc/php-fpm.d/www.conf

WORKDIR /var/www

EXPOSE 9000
CMD ["php-fpm"]
5 changes: 5 additions & 0 deletions .docker/php/bin/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh

set -e
php-fpm -D
nginx -g 'daemon off;'
17 changes: 17 additions & 0 deletions .docker/php/conf/php-fpm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[global]
error_log = /proc/self/fd/2

[www]
user = www-data
group = www-data

access.log = /proc/self/fd/1
listen = 127.0.0.1:9000
clear_env = no

pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.process_idle_timeout = 10s
16 changes: 16 additions & 0 deletions .docker/php/conf/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[php]
date.timezone = Europe/Warsaw
display_errors = Off
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
log_errors = 1
error_log = /proc/self/fd/2
catch_workers_output = yes
expose_php = Off
memory_limit=500M
max_execution_time = 900
[opcache]
opcache.enable = 1
opcache.enable_cli = 1
opcache.memory_consumption = 192
opcache.max_accelerated_files = 20000
opcache.interned_strings_buffer = 16
4 changes: 4 additions & 0 deletions .docker/php/conf/xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
xdebug.mode=develop,debug
xdebug.client_host=host.docker.internal
xdebug.start_with_request=yes
xdebug.client_port=9003
4 changes: 4 additions & 0 deletions .docker/php/conf/xdebug.ini.profiler.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
xdebug.mode=develop,debug,profiler
xdebug.client_host=host.docker.internal
xdebug.start_with_request=yes
xdebug.client_port=9003
9 changes: 9 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
APP_NAME=dev
APP_ENV=prod
APP_DEBUG=0

DB_HOST=db
DB_PORT=5432
DB_NAME=dbname
DB_USER=user
DB_PASSWORD=passwd
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: monthly
time: "07:30"
commit-message:
prefix: "#3 - (php) "
target-branch: main
open-pull-requests-limit: 1
11 changes: 11 additions & 0 deletions .github/workflows/check-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Check PR Title
on:
workflow_call:

jobs:
check-pr-title:
name: Check PR title
runs-on: ubuntu-20.04

steps:
- uses: blumilksoftware/action-pr-title@v1.2.0
44 changes: 44 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Test&lint PHP codebase

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
test-and-lint-php:
name: Test&lint PHP codebase
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache dependencies
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-composer-dependencies-${{ hashFiles('composer.lock') }}
restore-keys: ${{ runner.os }}-composer-dependencies

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, intl
coverage: none

- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction --no-suggest

- name: Run PHP linter
run: composer cs:check

- name: Run PHPSTAN
run: composer phpstan

- name: Execute tests
run: |
composer test
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.idea/
.vscode/
/coverage/
/vendor/
/logs/README.md
!/logs/README.md
.phpunit.result.cache

.idea
.build
.DS_Store
.composer

.env
/var
/vendor

/docker/postgresql-data
/logs/
19 changes: 19 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Options All -Indexes

<Files .htaccess>
order allow,deny
deny from all
</Files>

<IfModule mod_rewrite.c>
# Redirect to the public folder
RewriteEngine On
# RewriteBase /
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]

# Redirect to HTTPS
# RewriteEngine On
# RewriteCond %{HTTPS} off
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
14 changes: 14 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# How to Contribute

## Pull Requests

1. Fork the Slim Skeleton repository
2. Create a new branch for each feature or improvement
3. Send a pull request from each feature branch to the **4.x** branch

It is very important to separate new features or improvements into separate feature branches, and to send a
pull request for each branch. This allows us to review and pull in new features or improvements individually.

## Style Guide

All pull requests must adhere to the [PSR-12 standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-12-extended-coding-style-guide.md).
Loading

0 comments on commit 7d32310

Please sign in to comment.