Skip to content

Commit a8b3385

Browse files
committed
Refactoring
1 parent 630a114 commit a8b3385

File tree

12 files changed

+128
-76
lines changed

12 files changed

+128
-76
lines changed

.env

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -75,35 +75,51 @@ NETWORK_NAME_TRAEFIK_PUBLIC_LOCAL=traefik
7575
# Traefik network name (public)
7676
NETWORK_NAME_TRAEFIK_PUBLIC_PRODUCTION=traefik-public
7777

78-
# https port
78+
# https port (is usually not changed)
79+
PORT_HTTP=80
80+
81+
# https port (is usually not changed)
7982
PORT_HTTPS=443
8083

81-
# Internal docker adminer http port
84+
# Internal docker adminer http port (is usually not changed)
85+
PORT_MYSQL_INTERNAL=3306
86+
87+
# Internal docker adminer http port (is usually not changed)
8288
PORT_HTTP_ADMINER_INTERNAL=8080
8389

84-
# Internal docker mailhog http port
90+
# Internal docker mailhog http port (is usually not changed)
8591
PORT_HTTP_MAILHOG_INTERNAL=8025
8692

87-
# Internal docker mailhog smtp port
93+
# Internal docker mailhog smtp port (is usually not changed)
8894
PORT_SMTP_MAILHOG_INTERNAL=1025
8995

9096
# Expose api https port (To bypass the Traefik proxy or if it is not installed)
91-
PORT_HTTPS_API_EXPOSE=44443
97+
PORT_HTTP_APP_EXPOSE=5080
98+
99+
# Expose api https port (To bypass the Traefik proxy or if it is not installed)
100+
PORT_HTTPS_APP_EXPOSE=5043
101+
102+
# Expose db (mysql) port (External db app)
103+
# Attention for PORT_DB_MAIN_EXPOSE: Please also make changes to the DOCTRINE_DB_PORT variable.
104+
PORT_DB_MAIN_EXPOSE=5006
105+
106+
# Expose db (mysql) port (External db app)
107+
PORT_DB_TEST_EXPOSE=5007
92108

93109
# Expose adminer http port (To bypass the Traefik proxy or if it is not installed)
94-
PORT_HTTP_ADMINER_EXPOSE=8081
110+
PORT_HTTP_ADMINER_EXPOSE=5081
95111

96112
# Expose mailhog http port (To bypass the Traefik proxy or if it is not installed)
97-
PORT_HTTP_MAILHOG_EXPOSE=8082
113+
PORT_HTTP_MAILHOG_EXPOSE=5082
98114

99115
# Expose mailhog smtp port (To bypass the Traefik proxy or if it is not installed)
100-
PORT_SMTP_MAILHOG_EXPOSE=1025
116+
PORT_SMTP_MAILHOG_EXPOSE=5025
101117

102118
###< General Config / Docker Compose Settings ###
103119

104120
###> symfony/framework-bundle ###
105-
APP_ENV=dev
106-
APP_DEBUG=1
121+
APP_ENV=prod
122+
APP_DEBUG=0
107123
APP_SECRET=3b337448a0100c94f60efc26437e0a57
108124
###< symfony/framework-bundle ###
109125

@@ -115,11 +131,12 @@ PHP_VERSION_HOSTNAME=8-1-11
115131
###< PHP Configuration ###
116132

117133
###> Docker Configuration: MySQL secrets and configurations
134+
MYSQL_SERVER_HOST=127.0.0.1
118135
MYSQL_SERVER_ROOT_USER=root
119136
MYSQL_SERVER_ROOT_PASSWORD=secret-pass
120-
MYSQL_SERVER_DB=hdb
121-
MYSQL_SERVER_DB_TEST=hdb-test
122-
MYSQL_SERVER_PORT=3306
137+
MYSQL_SERVER_DB=pavb
138+
MYSQL_SERVER_DB_TEST=pavb-test
139+
MYSQL_SERVER_PORT=${PORT_MYSQL_INTERNAL}
123140
MYSQL_SERVER_VERSION=8.0
124141
MYSQL_SERVER_DRIVER=pdo_mysql
125142
###< Docker Configuration: MySQL secrets and configurations
@@ -131,12 +148,6 @@ MAIL_SERVER_HOST=localhost
131148
MAIL_SERVER_PORT=1025
132149
###< Docker Configuration: Mail secrets and configurations
133150

134-
###> Docker Configuration: General configurations
135-
# Attention for EXPOSE_MYSQL_PORT: Please also make changes to the DOCTRINE_DB_PORT variable.
136-
EXPOSE_MYSQL_PORT=3336
137-
EXPOSE_MYSQL_PORT_TEST=3337
138-
###< Docker Configuration: General configurations
139-
140151
##> doctrine/doctrine-bundle (mysql) ###
141152
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
142153
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
@@ -145,32 +156,15 @@ DOCTRINE_DB_VERSION=${MYSQL_SERVER_VERSION}
145156
DOCTRINE_DB_PATH=
146157
DOCTRINE_DB_NAME=${MYSQL_SERVER_DB}
147158
DOCTRINE_DB_HOST=${ENV_DB_HOST:-127.0.0.1}
148-
# Workaround for default port for DOCTRINE_DB_PORT: Because ${ENV_DB_PORT:-${EXPOSE_MYSQL_PORT}} does not work
149-
DOCTRINE_DB_PORT=${ENV_DB_PORT:-3336}
159+
# Workaround for default port for DOCTRINE_DB_PORT: Because ${ENV_DB_PORT:-${PORT_DB_MAIN_EXPOSE}} does not work
160+
DOCTRINE_DB_PORT=${ENV_DB_PORT:-50306}
150161
DOCTRINE_DB_USER=${MYSQL_SERVER_ROOT_USER}
151162
DOCTRINE_DB_PASS=${MYSQL_SERVER_ROOT_PASSWORD}
152163
DOCTRINE_DB_SSL_CA=
153164
DOCTRINE_DB_SSL_VERIFY_SERVER_CERT=false
154165
DOCTRINE_DB_INIT_COMMAND="SET NAMES utf8"
155166
###< doctrine/doctrine-bundle (mysql) ###
156167

157-
##> doctrine/doctrine-bundle (mysql) ###
158-
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
159-
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
160-
DOCTRINE_DB_DRIVER_SQLITE=${MYSQL_SERVER_DRIVER}
161-
DOCTRINE_DB_VERSION_SQLITE=${MYSQL_SERVER_VERSION}
162-
DOCTRINE_DB_PATH_SQLITE=
163-
DOCTRINE_DB_NAME_SQLITE=${MYSQL_SERVER_DB}
164-
DOCTRINE_DB_HOST_SQLITE=${ENV_DB_HOST:-127.0.0.1}
165-
# Workaround for default port for DOCTRINE_DB_PORT: Because ${ENV_DB_PORT:-${EXPOSE_MYSQL_PORT}} does not work
166-
DOCTRINE_DB_PORT_SQLITE=${ENV_DB_PORT:-3336}
167-
DOCTRINE_DB_USER_SQLITE=${MYSQL_SERVER_ROOT_USER}
168-
DOCTRINE_DB_PASS_SQLITE=${MYSQL_SERVER_ROOT_PASSWORD}
169-
DOCTRINE_DB_SSL_CA_SQLITE=
170-
DOCTRINE_DB_SSL_VERIFY_SERVER_CERT_SQLITE=false
171-
DOCTRINE_DB_INIT_COMMAND_SQLITE="SET NAMES utf8"
172-
###< doctrine/doctrine-bundle (mysql) ###
173-
174168
###> own variables ###
175169
PROJECT_NAME="PHP Api Version Bundle"
176170
PROJECT_DESCRIPTION="Provides the base API plattform functionality."
@@ -179,7 +173,7 @@ API_COUNTRY_CODE=de_DE
179173
###< own variables ###
180174

181175
###> table-dumper (local docker settings) ###
182-
MYSQLDUMP_DATABASE_URL=mysql://root:secret-pass@127.0.0.1:3336/hdb?serverVersion=8.0
176+
MYSQLDUMP_DATABASE_URL=mysql://${MYSQL_SERVER_ROOT_USER}:${MYSQL_SERVER_ROOT_PASSWORD}@${MYSQL_SERVER_HOST}:${MYSQL_SERVER_PORT}/${MYSQL_SERVER_DB}?serverVersion=${MYSQL_SERVER_VERSION}
183177
MYSQLDUMP_IGNORED_TABLES=
184178
#MYSQLDUMP_FILTERED_TABLES=
185179
#MYSQLDUMP_TABLES_NO_DATA=
@@ -191,5 +185,5 @@ CORS_ALLOW_ORIGIN='^https?://(php-api-version-bundle.ixnode.de|api-version.local
191185
###< nelmio/cors-bundle ###
192186

193187
###> symfony/mailer ###
194-
MAILER_DSN=smtp://localhost:1025
188+
MAILER_DSN=smtp://${MAIL_SERVER_PORT}:${MAIL_SERVER_PORT}
195189
###< symfony/mailer ###

.env.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ DOCTRINE_DB_VERSION=${MYSQL_SERVER_VERSION}
1414
DOCTRINE_DB_PATH="%kernel.project_dir%/var/app.db"
1515
DOCTRINE_DB_NAME=${MYSQL_SERVER_DB}
1616
DOCTRINE_DB_HOST=${ENV_DB_HOST:-127.0.0.1}
17-
# Workaround for default port for DOCTRINE_DB_PORT: Because ${ENV_DB_PORT:-${EXPOSE_MYSQL_PORT}} does not work
18-
DOCTRINE_DB_PORT=${ENV_DB_PORT:-3336}
17+
# Workaround for default port for DOCTRINE_DB_PORT: Because ${ENV_DB_PORT:-${PORT_DB_MAIN_EXPOSE}} does not work
18+
DOCTRINE_DB_PORT=${ENV_DB_PORT:-50306}
1919
DOCTRINE_DB_USER=${MYSQL_SERVER_ROOT_USER}
2020
DOCTRINE_DB_PASS=${MYSQL_SERVER_ROOT_PASSWORD}
2121
DOCTRINE_DB_SSL_CA=
2222
DOCTRINE_DB_SSL_VERIFY_SERVER_CERT=false
23-
DOCTRINE_DB_INIT_COMMAND=
23+
DOCTRINE_DB_INIT_COMMAND="SET NAMES utf8"
2424
###< doctrine/doctrine-bundle (sqlite) ###

composer.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@
9696

9797
"ixno:header": "bin/header/ixno",
9898

99-
"db:initialize:test": "bin/header/dbinit 'bin/console db:reinitialize --format=text --env=test' 'Test-DB Initialization'",
100-
"db:initialize:main": "for dump in fixtures/db/*.sql; do mysql -h127.0.0.1 -P3336 -uroot -psecret-pass --default-character-set=utf8 opa < \"$dump\"; done",
99+
"db:initialize:test:fixture": "bin/header/dbinit 'bin/console db:reinitialize --format=text --env=test' 'Test-DB Initialization'",
100+
"db:initialize:main:fixture": "bin/header/dbinit 'bin/console db:reinitialize --format=text --env=dev' 'Test-DB Initialization'",
101+
"db:initialize:main:sql": "for dump in fixtures/db/*.sql; do mysql -h127.0.0.1 -P3336 -uroot -psecret-pass --default-character-set=utf8 opa < \"$dump\"; done",
101102

102103
"doc:build:schema": "bin/console validator:schema data/json/api/private/power/private.power.json --reformat",
103104
"doc:build:endpoint": "bin/console document-generator:api --generate",
@@ -126,19 +127,19 @@
126127
"phpunit:functional:debug": "bin/header/phpunit 'PHPUNIT_DEBUG=1 vendor/bin/phpunit -d memory_limit=512M --configuration .phpunit/phpunit.functional.xml' 'Functional'",
127128
"phpunit:unit:debug": "bin/header/phpunit 'PHPUNIT_DEBUG=1 vendor/bin/phpunit -d memory_limit=512M --configuration .phpunit/phpunit.unit.xml' 'Unit'",
128129
"phpunit:all": [
129-
"@db:initialize:test",
130+
"@db:initialize:test:fixture",
130131
"@phpunit:unit",
131132
"@phpunit:functional",
132133
"@phpunit:api"
133134
],
134135
"phpunit:all:coverage": [
135-
"@db:initialize:test",
136+
"@db:initialize:test:fixture",
136137
"@phpunit:unit:coverage",
137138
"@phpunit:functional:coverage",
138139
"@phpunit:api:coverage"
139140
],
140141
"phpunit:all:debug": [
141-
"@db:initialize:test",
142+
"@db:initialize:test:fixture",
142143
"@phpunit:unit:debug",
143144
"@phpunit:functional:debug",
144145
"@phpunit:api:debug"
@@ -255,8 +256,9 @@
255256
".test:hardcore": " ",
256257
".test:most": " ",
257258

258-
"db:initialize:test": "Initializes the test db.",
259-
"db:initialize:main": "Initializes the main db.",
259+
"db:initialize:test:fixture": "Initializes the test db via fixtures.",
260+
"db:initialize:main:fixture": "Initializes the main db via fixtures.",
261+
"db:initialize:main:sql": "Initializes the main db via sql dumps.",
260262

261263
"doc:build:schema": "Builds schema documents.",
262264
"doc:build:endpoint": "Builds endpoint documents.",

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/packages/doctrine.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ doctrine:
1212
user: "%env(resolve:DOCTRINE_DB_USER)%"
1313
password: "%env(resolve:DOCTRINE_DB_PASS)%"
1414
sqlite:
15-
driver: "%env(resolve:DOCTRINE_DB_DRIVER_SQLITE)%"
16-
server_version: "%env(resolve:DOCTRINE_DB_VERSION_SQLITE)%"
17-
path: "%env(resolve:DOCTRINE_DB_PATH_SQLITE)%"
18-
dbname: "%env(resolve:DOCTRINE_DB_NAME_SQLITE)%"
19-
host: "%env(resolve:DOCTRINE_DB_HOST_SQLITE)%"
20-
port: "%env(resolve:DOCTRINE_DB_PORT_SQLITE)%"
21-
user: "%env(resolve:DOCTRINE_DB_USER_SQLITE)%"
22-
password: "%env(resolve:DOCTRINE_DB_PASS_SQLITE)%"
15+
driver: "%env(resolve:DOCTRINE_DB_DRIVER)%"
16+
server_version: "%env(resolve:DOCTRINE_DB_VERSION)%"
17+
path: "%env(resolve:DOCTRINE_DB_PATH)%"
18+
dbname: "%env(resolve:DOCTRINE_DB_NAME)%"
19+
host: "%env(resolve:DOCTRINE_DB_HOST)%"
20+
port: "%env(resolve:DOCTRINE_DB_PORT)%"
21+
user: "%env(resolve:DOCTRINE_DB_USER)%"
22+
password: "%env(resolve:DOCTRINE_DB_PASS)%"
2323

2424
orm:
2525
auto_generate_proxy_classes: true

config/routes/api_platform.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
api_platform:
22
resource: .
33
type: api_platform
4-
prefix: /api
4+
prefix: '%api.base_url%'

config/services.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# Put parameters here that don't need to change on each machine where the app is deployed
55
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
66
parameters:
7+
api.base_url: '%env(resolve:API_BASE_URL)%'
8+
api.cors_allow_origin: '%env(CORS_ALLOW_ORIGIN)%'
9+
api.country_code: '%env(resolve:API_COUNTRY_CODE)%'
710

811
services:
912
# default configuration for services in *this* file

docker-compose.override.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ services:
6262
# Nginx to serve the app.
6363
nginx:
6464
ports:
65-
- "${PORT_HTTPS_API_EXPOSE}:${PORT_HTTPS}"
65+
- "${PORT_HTTPS_APP_EXPOSE}:${PORT_HTTPS}"
6666
networks:
6767
- network-internal
6868
- network-traefik
@@ -88,10 +88,15 @@ services:
8888
# network
8989
- "traefik.docker.network=${NETWORK_NAME_TRAEFIK_PUBLIC_LOCAL}"
9090

91-
# MySQL 5.7.39 Server
91+
# MySQL 8.0.31 Server
9292
database:
9393
ports:
94-
- ${EXPOSE_MYSQL_PORT}:${MYSQL_SERVER_PORT}
94+
- ${PORT_DB_MAIN_EXPOSE}:${MYSQL_SERVER_PORT}
95+
96+
# MySQL 8.0.31 Server
97+
database-test:
98+
ports:
99+
- ${PORT_DB_TEST_EXPOSE}:${MYSQL_SERVER_PORT}
95100

96101
# Adminer MySQL Client
97102
adminer:

docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ services:
132132
ENV_MAIL_SERVER_HOST: "${MAIL_SERVER_HOST}"
133133
ENV_MAIL_SERVER_PORT: "${MAIL_SERVER_PORT}"
134134
# some ports
135-
ENV_EXPOSE_API_HTTPS_PORT: "${PORT_HTTPS_API_EXPOSE}"
135+
ENV_EXPOSE_APP_HTTPS_PORT: "${PORT_HTTPS_APP_EXPOSE}"
136+
ENV_EXPOSE_APP_HTTP_PORT: "${PORT_HTTP_APP_EXPOSE}"
136137
depends_on:
137138
- database
138139
- database-test

rector.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the ixnode/php-api-version-bundle project.
7+
*
8+
* (c) Björn Hempel <https://www.hempel.li/>
9+
*
10+
* For the full copyright and license information, please view the LICENSE.md
11+
* file that was distributed with this source code.
12+
*/
13+
14+
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
15+
use Rector\Config\RectorConfig;
16+
use Rector\Doctrine\Set\DoctrineSetList;
17+
use Rector\Php80\Rector\FunctionLike\MixedTypeRector;
18+
use Rector\Php80\Rector\FunctionLike\UnionTypesRector;
19+
use Rector\Set\ValueObject\LevelSetList;
20+
use Rector\Symfony\Set\SensiolabsSetList;
21+
use Rector\Symfony\Set\SymfonySetList;
22+
23+
return static function (RectorConfig $rectorConfig): void {
24+
$rectorConfig->paths([
25+
__DIR__ . '/src',
26+
__DIR__ . '/tests',
27+
]);
28+
29+
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
30+
31+
$rectorConfig->sets([
32+
LevelSetList::UP_TO_PHP_81,
33+
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
34+
SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES,
35+
SensiolabsSetList::FRAMEWORK_EXTRA_61,
36+
]);
37+
38+
/* Ignore additional type hints (param, return) within doc blocks */
39+
$rectorConfig->skip([
40+
MixedTypeRector::class,
41+
UnionTypesRector::class,
42+
]);
43+
};

0 commit comments

Comments
 (0)