Skip to content

Commit 737a423

Browse files
authored
Merge pull request #10 from xsga/7.2.0
7.2.0
2 parents 7c006b3 + b524544 commit 737a423

File tree

72 files changed

+327
-508
lines changed

Some content is hidden

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

72 files changed

+327
-508
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2
33
jobs:
44
build:
55
docker:
6-
- image: cimg/php:8.3.6
6+
- image: cimg/php:8.4.4
77

88
steps:
99
- checkout

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"image": "mcr.microsoft.com/devcontainers/php:8.3",
2+
"image": "mcr.microsoft.com/devcontainers/php:8.4",
33
"customizations": {
44
"vscode": {
55
"extensions": [

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup PHP
2020
uses: shivammathur/setup-php@v2
2121
with:
22-
php-version: '8.3'
22+
php-version: '8.4'
2323
extensions: mbstring, zip, gd, pdo_mysql, sockets
2424

2525
- name: Checkout code

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:8.3.6-apache
1+
FROM php:8.4.4-apache
22

33
ARG DEBIAN_FRONTEND=noninteractive
44

composer.json

Lines changed: 55 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,59 @@
11
{
2-
"name": "xsga/film-affinity-api",
3-
"description": "A non official FilmAffinity API",
4-
"type": "project",
5-
"license": "MIT",
6-
"authors": [
7-
{
8-
"name": "Parker",
9-
"email": "parker@xsga.es"
10-
}
2+
"name": "xsga/film-affinity-api",
3+
"description": "A non official FilmAffinity API",
4+
"type": "project",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Parker",
9+
"email": "parker@xsga.es"
10+
}
11+
],
12+
"require": {
13+
"php": "^8.4",
14+
"slim/slim": "4.*",
15+
"slim/psr7": "^1.7",
16+
"vlucas/phpdotenv": "^5.6",
17+
"doctrine/orm": "^3.3",
18+
"symfony/console": "^7.2",
19+
"php-di/php-di": "^7.0",
20+
"guzzlehttp/guzzle": "^7.9",
21+
"swaggest/json-schema": "^0.12.43",
22+
"firebase/php-jwt": "^6.10",
23+
"symfony/cache": "^7.2"
24+
},
25+
"require-dev": {
26+
"squizlabs/php_codesniffer": "^3.7",
27+
"vimeo/psalm": "^6.8",
28+
"php-parallel-lint/php-parallel-lint": "^1.3",
29+
"php-parallel-lint/php-console-highlighter": "^1.0"
30+
},
31+
"autoload": {
32+
"files": [
33+
"src/Xsga/FilmAffinityApi/Bootstrap/Bootstrap.php",
34+
"src/Xsga/FilmAffinityApi/Bootstrap/DIContainer.php",
35+
"src/Xsga/FilmAffinityApi/Bootstrap/GetPath.php",
36+
"config/app/SlimApp.php",
37+
"config/env/Settings.php",
38+
"config/routes/Routes.php"
1139
],
12-
"require": {
13-
"php": "^8.3",
14-
"slim/slim": "4.*",
15-
"slim/psr7": "^1.6",
16-
"vlucas/phpdotenv": "^5.5",
17-
"doctrine/orm": "^2.16",
18-
"php-di/php-di": "^7.0",
19-
"guzzlehttp/guzzle": "^7.0",
20-
"swaggest/json-schema": "^0.12.41",
21-
"firebase/php-jwt": "^6.8",
22-
"symfony/cache": "^6.3",
23-
"symfony/console": "^6.3"
24-
},
25-
"require-dev": {
26-
"squizlabs/php_codesniffer": "^3.7",
27-
"php-parallel-lint/php-parallel-lint": "^1.3",
28-
"php-parallel-lint/php-console-highlighter": "^1.0",
29-
"vimeo/psalm": "^5.24"
30-
},
31-
"autoload": {
32-
"files": [
33-
"src/Xsga/FilmAffinityApi/Bootstrap/Bootstrap.php",
34-
"src/Xsga/FilmAffinityApi/Bootstrap/DIContainer.php",
35-
"src/Xsga/FilmAffinityApi/Bootstrap/GetPath.php",
36-
"config/app/SlimApp.php",
37-
"config/env/Settings.php",
38-
"config/routes/Routes.php"
39-
],
40-
"psr-4": {
41-
"Xsga\\FilmAffinityApi\\": "src/Xsga/FilmAffinityApi/",
42-
"Log4Php\\": "src/Log4Php/"
43-
}
44-
},
45-
"scripts": {
46-
"style": "phpcs -p --colors --standard=PSR12 src public",
47-
"style-fix": "phpcbf -p --standard=PSR12 src public",
48-
"lint": "parallel-lint --exclude vendor .",
49-
"analyze-errors": "psalm --output-format=console --show-info=false --no-cache",
50-
"analyze-info": "psalm --output-format=console --show-info=true --no-cache",
51-
"phploc": "phploc --exclude Src/Log4Php Src"
40+
"psr-4": {
41+
"Xsga\\FilmAffinityApi\\": "src/Xsga/FilmAffinityApi/",
42+
"Log4Php\\": "src/Log4Php/"
43+
}
44+
},
45+
"scripts": {
46+
"lint": "parallel-lint --exclude vendor .",
47+
"style": "phpcs -p --colors --standard=PSR12 src public",
48+
"style-fix": "phpcbf -p --standard=PSR12 src public",
49+
"analyze-errors": "psalm --output-format=console --show-info=false --no-cache",
50+
"analyze-info": "psalm --output-format=console --show-info=true --no-cache",
51+
"phploc": "phploc --exclude Src/Log4Php Src"
52+
},
53+
"config": {
54+
"allow-plugins": {
55+
"php-http/discovery": false,
56+
"tbachert/spi": true
5257
}
58+
}
5359
}

config/app/SlimApp.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ function getSlimApp(ContainerInterface $container): App
1313
// Slim app.
1414
AppFactory::setContainer($container);
1515
$app = AppFactory::create();
16-
$app->setBasePath($container->get('getUrlPath'));
16+
$app->setBasePath($container->get('env.url.path'));
1717

1818
// Middlewares.
1919
$app->add(SecurityMiddleware::class);
2020
$app->addRoutingMiddleware();
2121
$app->addBodyParsingMiddleware();
2222

2323
// Error handler.
24-
$errorMiddleware = $app->addErrorMiddleware($container->get('getErrorDetail'), true, true);
24+
$errorMiddleware = $app->addErrorMiddleware($container->get('env.error.detail'), true, true);
2525
$errorMiddleware->setDefaultErrorHandler(ErrorHandler::class);
2626

2727
// Load routes.

config/container/Container.php

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
use Xsga\FilmAffinityApi\Modules\Films\Application\Mappers\GenreToGenreDto;
2020
use Xsga\FilmAffinityApi\Modules\Films\Application\Services\BackupCountriesService;
2121
use Xsga\FilmAffinityApi\Modules\Films\Application\Services\BackupGenresService;
22-
use Xsga\FilmAffinityApi\Modules\Films\Domain\Parsers\AdvancedSearchFormParser;
23-
use Xsga\FilmAffinityApi\Modules\Films\Domain\Parsers\AdvancedSearchParser;
2422
use Xsga\FilmAffinityApi\Modules\Films\Domain\Repositories\AdvancedSearchRepository;
2523
use Xsga\FilmAffinityApi\Modules\Films\Domain\Repositories\CountriesRepository;
2624
use Xsga\FilmAffinityApi\Modules\Films\Domain\Repositories\FilmsRepository;
@@ -63,31 +61,33 @@
6361
// --------------------------------------------------------------------------------------------
6462

6563
// FOLDERS.
66-
'root.folder' => getPathTo(),
67-
'entity.folders' => [getPathTo('src#Xsga#FilmAffinityApi#Modules#Shared#Persistence#Infrastructure#Doctrine')],
68-
'schema.folder' => getPathTo('config#schemas#input'),
69-
'backup.folder' => getPathTo('data#backup'),
64+
'root.folder' => getPathTo(),
65+
'entity.folders' => [
66+
getPathTo('src#Xsga#FilmAffinityApi#Modules#Shared#Persistence#Infrastructure#Doctrine'),
67+
],
68+
'schema.folder' => getPathTo('config#schemas#input'),
69+
'backup.folder' => getPathTo('data#backup'),
7070
'entities.proxy.folder' => getPathTo('tmp#doctrine-proxies'),
71-
'logger.config.folder' => getPathTo('config#logger'),
72-
'errors.folder' => getPathTo('config#errors'),
73-
'cache.folder' => getPathTo('tmp#cache'),
71+
'logger.config.folder' => getPathTo('config#logger'),
72+
'errors.folder' => getPathTo('config#errors'),
73+
'cache.folder' => getPathTo('tmp#cache'),
7474

7575
// ENVIRONMENT.
76-
'getLanguage' => $_ENV['LANGUAGE'],
77-
'getErrorDetail' => filter_var($_ENV['ERROR_DETAIL'], FILTER_VALIDATE_BOOLEAN),
78-
'getLogSQL' => filter_var($_ENV['LOG_SQL'], FILTER_VALIDATE_BOOLEAN),
79-
'getUrlPath' => $_ENV['URL_PATH'],
80-
'getJwtSecretKey' => $_ENV['JWT_SECRET_KEY'],
81-
'getJwtLifetime' => (int)$_ENV['JWT_LIFETIME'],
82-
'getSecurityType' => function () {
76+
'env.language' => $_ENV['LANGUAGE'],
77+
'env.error.detail' => filter_var($_ENV['ERROR_DETAIL'], FILTER_VALIDATE_BOOLEAN),
78+
'env.log.sql' => filter_var($_ENV['LOG_SQL'], FILTER_VALIDATE_BOOLEAN),
79+
'env.url.path' => $_ENV['URL_PATH'],
80+
'env.jwt.secret.key' => $_ENV['JWT_SECRET_KEY'],
81+
'env.jwt.lifetime' => (int)$_ENV['JWT_LIFETIME'],
82+
'env.security.type' => function (): SecurityTypes {
8383
return match ($_ENV['SECURITY_TYPE']) {
8484
'basic' => SecurityTypes::BASIC,
8585
'token' => SecurityTypes::TOKEN
8686
};
8787
},
88-
'getDateMask' => 'd/m/Y',
89-
'getDateTimeMask' => 'd/m/Y H:i:s',
90-
'database.info' => [
88+
'env.date.mask' => 'd/m/Y',
89+
'env.datetime.mask' => 'd/m/Y H:i:s',
90+
'env.database.info' => [
9191
'driver' => 'pdo_mysql',
9292
'dbname' => $_ENV['DB_SCHEMA'],
9393
'user' => $_ENV['DB_USER'],
@@ -98,12 +98,12 @@
9898
],
9999

100100
// FILMAFFINITY.
101-
'filmaffinity.baseURL' => $_ENV['BASE_URL'],
102-
'filmaffinity.searchURL' => $_ENV['SEARCH_URL'],
101+
'filmaffinity.baseURL' => $_ENV['BASE_URL'],
102+
'filmaffinity.searchURL' => $_ENV['SEARCH_URL'],
103103
'filmaffinity.advancedSearchURL' => $_ENV['ADV_SEARCH_URL'],
104-
'filmaffinity.filmURL' => $_ENV['FILM_URL'],
105-
'filmaffinity.getBaseURL' => function (ContainerInterface $container): string {
106-
return match (strtolower($container->get('getLanguage'))) {
104+
'filmaffinity.filmURL' => $_ENV['FILM_URL'],
105+
'filmaffinity.getBaseURL' => function (ContainerInterface $container): string {
106+
return match (strtolower($container->get('env.language'))) {
107107
'spa' => $container->get('filmaffinity.baseURL') . 'es/',
108108
'en' => $container->get('filmaffinity.baseURL') . 'us/'
109109
};
@@ -112,39 +112,39 @@
112112
// --------------------------------------------------------------------------------------------
113113
// ENTITY MANAGER.
114114
// --------------------------------------------------------------------------------------------
115-
EntityManagerInterface::class => function (ContainerInterface $container) {
115+
EntityManagerInterface::class => function (ContainerInterface $container): EntityManager {
116116
$isDevMode = true;
117117
$entityPaths = $container->get('entity.folders');
118118
$proxyPath = $container->get('entities.proxy.folder');
119119

120120
$config = ORMSetup::createAttributeMetadataConfiguration($entityPaths, $isDevMode, $proxyPath, null);
121121
$config->setAutoGenerateProxyClasses($isDevMode);
122122

123-
if ($container->get('getLogSQL')) {
123+
if ($container->get('env.log.sql')) {
124124
$config->setMiddlewares([$container->get(Middleware::class)]);
125125
}
126126

127-
$connection = DriverManager::getConnection($container->get('database.info'), $config);
127+
$connection = DriverManager::getConnection($container->get('env.database.info'), $config);
128128

129129
return new EntityManager($connection, $config);
130130
},
131131

132132
// --------------------------------------------------------------------------------------------
133133
// LOGGER.
134134
// --------------------------------------------------------------------------------------------
135-
Logger::class => function (ContainerInterface $container) {
135+
Logger::class => function (ContainerInterface $container): Logger {
136136
if (!Logger::isInitialized()) {
137137
Logger::configure($container->get('logger.config.folder') . 'log4php.xml');
138138
}
139139
return Logger::getRootLogger();
140140
},
141-
'logger-cli' => function (ContainerInterface $container) {
141+
'logger-cli' => function (ContainerInterface $container): Logger {
142142
if (!Logger::isInitialized()) {
143143
Logger::configure($container->get('logger.config.folder') . 'log4php-cli.xml');
144144
}
145145
return Logger::getRootLogger();
146146
},
147-
LoggerInterface::class => function (ContainerInterface $container): LoggerInterface {
147+
LoggerInterface::class => function (ContainerInterface $container): LoggerWrapper {
148148
$logger = match (php_sapi_name()) {
149149
'cli' => $container->get('logger-cli'),
150150
default => $container->get(Logger::class)
@@ -162,7 +162,7 @@
162162
DI\get(GetSchemaService::class),
163163
DI\get(JsonLoaderService::class),
164164
DI\get('errors.folder'),
165-
DI\get('getLanguage'),
165+
DI\get('env.language'),
166166
DI\get(JsonErrorToError::class)
167167
),
168168

@@ -172,7 +172,7 @@
172172

173173
// Application mappers.
174174
UserToUserDto::class => DI\create(UserToUserDto::class)->constructor(
175-
DI\get('getDateTimeMask')
175+
DI\get('env.datetime.mask')
176176
),
177177

178178
// Domain repositories.
@@ -192,15 +192,15 @@
192192
DI\get(LoggerInterface::class),
193193
DI\get(FilmAffinityGenresRepository::class),
194194
DI\get(GenreToGenreDto::class),
195-
DI\get('getLanguage'),
195+
DI\get('env.language'),
196196
DI\get('backup.folder')
197197
),
198198

199199
BackupCountriesService::class => DI\create(BackupCountriesService::class)->constructor(
200200
DI\get(LoggerInterface::class),
201201
DI\get(FilmAffinityCountriesRepository::class),
202202
DI\get(CountryToCountryDto::class),
203-
DI\get('getLanguage'),
203+
DI\get('env.language'),
204204
DI\get('backup.folder')
205205
),
206206

@@ -262,8 +262,8 @@
262262
// JWT application services.
263263
JWTService::class => DI\create(FirebaseJwtService::class)->constructor(
264264
DI\get(LoggerInterface::class),
265-
DI\get('getJwtSecretKey'),
266-
DI\get('getJwtLifetime')
265+
DI\get('env.jwt.secret.key'),
266+
DI\get('env.jwt.lifetime')
267267
),
268268

269269
// HTTP CLIENT application services.
@@ -277,6 +277,6 @@
277277
DI\get(LoggerInterface::class),
278278
DI\get(BasicSecurityService::class),
279279
DI\get(TokenSecurityService::class),
280-
DI\get('getSecurityType')
280+
DI\get('env.security.type')
281281
),
282282
];

config/env/Settings.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ function loadEnvironmentSettings(): void
1313
$settings->required('ERROR_DETAIL')->isBoolean();
1414
$settings->required('LOG_SQL')->isBoolean();
1515
$settings->required('LANGUAGE')->allowedValues(['spa', 'en']);
16-
$settings->required('BASE_URL');
17-
$settings->required('SEARCH_URL');
18-
$settings->required('ADV_SEARCH_URL');
19-
$settings->required('FILM_URL');
2016
$settings->required('SECURITY_TYPE')->allowedValues(['basic', 'token']);
2117
$settings->required('JWT_LIFETIME')->isInteger();
2218
$settings->required('JWT_SECRET_KEY');
23-
$settings->required('DB_SCHEMA');
19+
$settings->required('DB_HOST');
2420
$settings->required('DB_USER');
2521
$settings->required('DB_PASSWORD');
26-
$settings->required('DB_HOST');
22+
$settings->required('DB_SCHEMA');
2723
$settings->required('DB_PORT');
24+
$settings->required('BASE_URL');
25+
$settings->required('SEARCH_URL');
26+
$settings->required('ADV_SEARCH_URL');
27+
$settings->required('FILM_URL');
2828
}

config/logger/log4php-cli.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<layout class="LoggerLayoutPattern">
66
<param name="conversionPattern" value="%date{Y-m-d H:i:s} [%5pid] [%-5level] [%-30class{0}] [%4line] - %msg%n" />
77
</layout>
8-
<param name="file" value="../Log/log_cli-%s.log" />
8+
<param name="file" value="../log/log_cli-%s.log" />
99
<param name="datePattern" value="Ymd" />
1010
</appender>
1111

config/routes/Routes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313
function getRoutes(App $slimApp): App
1414
{
15-
$slimApp->get('/films/{id:[0-9]+}', GetFilmByIdController::class)->setName('get_film_by_id');
16-
$slimApp->post('/users/token', GetTokenController::class)->setName('get_token');
1715
$slimApp->post('/searches/simple', SimpleSearchController::class)->setName('simple_search');
1816
$slimApp->post('/searches/advanced', AdvancedSearchController::class)->setName('advanced_search');
17+
$slimApp->get('/films/{id:[0-9]+}', GetFilmByIdController::class)->setName('get_film_by_id');
1918
$slimApp->get('/genres', GetAllGenresController::class)->setName('get_all_genres');
2019
$slimApp->get('/countries', GetAllCountriesController::class)->setName('get_all_countries');
20+
$slimApp->post('/users/token', GetTokenController::class)->setName('get_token');
2121

2222
return $slimApp;
2323
}

0 commit comments

Comments
 (0)