Skip to content

Commit 9b4e736

Browse files
committed
Implementation according to the https://github.com/pvaviloff/php-guidelines
1 parent 22deec4 commit 9b4e736

File tree

83 files changed

+11301
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+11301
-0
lines changed

.docker/nginx/default.conf

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
server {
2+
listen 80;
3+
client_max_body_size 32m;
4+
access_log /var/log/nginx/access.log;
5+
root /var/www/html/public;
6+
fastcgi_buffers 16 16k;
7+
fastcgi_buffer_size 32k;
8+
9+
location / {
10+
try_files $uri /index.php$is_args$args;
11+
}
12+
13+
location ~ ^/index\.php(/|$) {
14+
root /var/www/html/public;
15+
fastcgi_pass app-php:9000;
16+
fastcgi_index index.php;
17+
fastcgi_split_path_info ^(.+\.php)(/.*)$;
18+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
19+
include fastcgi_params;
20+
}
21+
22+
}

.docker/supervisor/supervisord.conf

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[supervisord]
2+
nodaemon=true
3+
user=root
4+
5+
[program:php-fpm]
6+
command=php-fpm
7+
user=root
8+
stdout_logfile=/dev/stdout
9+
stdout_logfile_maxbytes=0
10+
stderr_logfile=/dev/stderr
11+
stderr_logfile_maxbytes=0
12+
13+
[program:messenger-consume]
14+
command=php /var/www/html/bin/console messenger:consume async --time-limit=3600
15+
user=root
16+
numprocs=2
17+
startsecs=0
18+
autostart=true
19+
autorestart=true
20+
startretries=10
21+
process_name=%(program_name)s_%(process_num)02d

.env

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# In all environments, the following files are loaded if they exist,
2+
# the latter taking precedence over the former:
3+
#
4+
# * .env contains default values for the environment variables needed by the app
5+
# * .env.local uncommitted file with local overrides
6+
# * .env.$APP_ENV committed environment-specific defaults
7+
# * .env.$APP_ENV.local uncommitted environment-specific overrides
8+
#
9+
# Real environment variables win over .env files.
10+
#
11+
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
12+
# https://symfony.com/doc/current/configuration/secrets.html
13+
#
14+
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
15+
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
16+
17+
###> symfony/framework-bundle ###
18+
APP_ENV=dev
19+
APP_SECRET=543b78666203f44fb1e0f89829bf12ec
20+
###< symfony/framework-bundle ###
21+
22+
NGINX_PORT=80
23+
24+
POSTGRES_HOST=postgres
25+
POSTGRES_PORT=5432
26+
POSTGRES_DB=app
27+
POSTGRES_USER=app
28+
POSTGRES_PASSWORD=ppa
29+
30+
VALKEY_PORT=6379
31+
VALKEY_CONNECTION=redis://valkey:6379
32+
33+
###> symfony/messenger ###
34+
MESSENGER_TRANSPORT_DSN=redis://valkey:6379/messages
35+
###< symfony/messenger ###

.env.test

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# define your env variables for the test env here
2+
KERNEL_CLASS='App\Kernel'
3+
APP_SECRET='$ecretf0rt3st'
4+
SYMFONY_DEPRECATIONS_HELPER=999999
5+
PANTHER_APP_ENV=panther
6+
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots

.gitignore

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
###> symfony/framework-bundle ###
2+
/.env.local
3+
/.env.local.php
4+
/.env.*.local
5+
/config/secrets/prod/prod.decrypt.private.php
6+
/public/bundles/
7+
/var/
8+
/vendor/
9+
###< symfony/framework-bundle ###
10+
11+
.idea/
12+
.deptrac.cache
13+
14+
###> symfony/phpunit-bridge ###
15+
.phpunit.result.cache
16+
/phpunit.xml
17+
###< symfony/phpunit-bridge ###
18+
19+
###> phpunit/phpunit ###
20+
/phpunit.xml
21+
.phpunit.result.cache
22+
###< phpunit/phpunit ###

Dockerfile

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
FROM php:8.3-fpm
2+
3+
LABEL maintainer="Pavlo Vavilov <[email protected]>"
4+
5+
ENV USER_UID 1000
6+
ENV USER_NAME app
7+
ENV USER_HOME /home/app
8+
9+
WORKDIR /var/www/html
10+
11+
ADD .docker/supervisor/supervisord.conf /etc/supervisor/conf.d/
12+
13+
14+
RUN apt-get update && apt-get install -y \
15+
libpq-dev \
16+
libonig-dev \
17+
libzip-dev \
18+
unzip \
19+
supervisor \
20+
&& docker-php-ext-install pcntl \
21+
&& docker-php-ext-install bcmath \
22+
&& docker-php-ext-install mbstring \
23+
&& docker-php-ext-install zip \
24+
&& docker-php-ext-install pdo \
25+
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
26+
&& docker-php-ext-install pgsql pdo_pgsql
27+
28+
29+
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
30+
&& php composer-setup.php \
31+
&& php -r "unlink('composer-setup.php');" \
32+
&& mv composer.phar /usr/local/bin/composer
33+
34+
35+
CMD ["/bin/bash", "-c", "/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf"]

bin/console

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use App\Kernel;
5+
use Symfony\Bundle\FrameworkBundle\Console\Application;
6+
7+
if (!is_dir(dirname(__DIR__).'/vendor')) {
8+
throw new LogicException('Dependencies are missing. Try running "composer install".');
9+
}
10+
11+
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
12+
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
13+
}
14+
15+
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
16+
17+
return function (array $context) {
18+
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
19+
20+
return new Application($kernel);
21+
};

bin/phpunit

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
if (!ini_get('date.timezone')) {
5+
ini_set('date.timezone', 'UTC');
6+
}
7+
8+
if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
9+
if (PHP_VERSION_ID >= 80000) {
10+
require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit';
11+
} else {
12+
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
13+
require PHPUNIT_COMPOSER_INSTALL;
14+
PHPUnit\TextUI\Command::main();
15+
}
16+
} else {
17+
if (!is_file(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
18+
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
19+
exit(1);
20+
}
21+
22+
require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php';
23+
}

composer.json

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"type": "project",
3+
"license": "proprietary",
4+
"minimum-stability": "stable",
5+
"prefer-stable": true,
6+
"require": {
7+
"php": ">=8.2",
8+
"ext-ctype": "*",
9+
"ext-iconv": "*",
10+
"doctrine/dbal": "^3",
11+
"doctrine/doctrine-bundle": "^2.12",
12+
"doctrine/doctrine-migrations-bundle": "^3.3",
13+
"doctrine/orm": "^3.2",
14+
"nelmio/api-doc-bundle": "^4.28",
15+
"phpdocumentor/reflection-docblock": "^5.4",
16+
"phpstan/phpdoc-parser": "^1.29",
17+
"ramsey/collection": "^2.0",
18+
"symfony/asset": "7.1.*",
19+
"symfony/console": "7.1.*",
20+
"symfony/dotenv": "7.1.*",
21+
"symfony/flex": "^2",
22+
"symfony/framework-bundle": "7.1.*",
23+
"symfony/messenger": "7.1.*",
24+
"symfony/property-access": "7.1.*",
25+
"symfony/property-info": "7.1.*",
26+
"symfony/runtime": "7.1.*",
27+
"symfony/serializer": "7.1.*",
28+
"symfony/twig-bundle": "7.1.*",
29+
"symfony/uid": "7.1.*",
30+
"symfony/validator": "7.1.*",
31+
"symfony/yaml": "7.1.*"
32+
},
33+
"require-dev": {
34+
"dama/doctrine-test-bundle": "^8.2",
35+
"doctrine/doctrine-fixtures-bundle": "^3.6",
36+
"phpunit/phpunit": "^9.5",
37+
"qossmic/deptrac": "^2.0",
38+
"symfony/browser-kit": "7.1.*",
39+
"symfony/css-selector": "7.1.*",
40+
"symfony/maker-bundle": "^1.60",
41+
"symfony/phpunit-bridge": "^7.1",
42+
"vimeo/psalm": "^5.25"
43+
},
44+
"config": {
45+
"allow-plugins": {
46+
"php-http/discovery": true,
47+
"symfony/flex": true,
48+
"symfony/runtime": true
49+
},
50+
"sort-packages": true
51+
},
52+
"autoload": {
53+
"psr-4": {
54+
"App\\": "src/"
55+
}
56+
},
57+
"autoload-dev": {
58+
"psr-4": {
59+
"App\\Tests\\": "tests/"
60+
}
61+
},
62+
"replace": {
63+
"symfony/polyfill-ctype": "*",
64+
"symfony/polyfill-iconv": "*",
65+
"symfony/polyfill-php72": "*",
66+
"symfony/polyfill-php73": "*",
67+
"symfony/polyfill-php74": "*",
68+
"symfony/polyfill-php80": "*",
69+
"symfony/polyfill-php81": "*",
70+
"symfony/polyfill-php82": "*"
71+
},
72+
"scripts": {
73+
"auto-scripts": {
74+
"cache:clear": "symfony-cmd",
75+
"assets:install %PUBLIC_DIR%": "symfony-cmd"
76+
},
77+
"post-install-cmd": [
78+
"@auto-scripts"
79+
],
80+
"post-update-cmd": [
81+
"@auto-scripts"
82+
]
83+
},
84+
"conflict": {
85+
"symfony/symfony": "*"
86+
},
87+
"extra": {
88+
"symfony": {
89+
"allow-contrib": false,
90+
"require": "7.1.*"
91+
}
92+
}
93+
}

0 commit comments

Comments
 (0)