Skip to content

Commit 97777f0

Browse files
committed
small fixes, removed dot-errorhandler and added dot-log
Signed-off-by: sergiu <[email protected]>
1 parent fe0e9d3 commit 97777f0

File tree

13 files changed

+71
-189
lines changed

13 files changed

+71
-189
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
require_once 'vendor/autoload.php';
6+
7+
const ENVIRONMENT_DEVELOPMENT = 'development';
8+
const ENVIRONMENT_PRODUCTION = 'production';
9+
10+
// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
11+
12+
/**
13+
* @param array{source: string, destination: string, environment: array<string>} $file
14+
*/
15+
function copyFile(array $file): void
16+
{
17+
if (! in_array(getEnvironment(), $file['environment'])) {
18+
echo "Skipping the copy of {$file['source']} due to environment settings." . PHP_EOL;
19+
return;
20+
}
21+
22+
if (is_readable($file['destination'])) {
23+
echo "File {$file['destination']} already exists. Skipping..." . PHP_EOL;
24+
return;
25+
}
26+
27+
if (! copy($file['source'], $file['destination'])) {
28+
echo "Cannot copy {$file['source']} file to {$file['destination']}" . PHP_EOL;
29+
} else {
30+
echo "File {$file['source']} copied successfully to {$file['destination']}." . PHP_EOL;
31+
}
32+
}
33+
34+
function getEnvironment(): string
35+
{
36+
return getenv('COMPOSER_DEV_MODE') === '1' ? ENVIRONMENT_DEVELOPMENT : ENVIRONMENT_PRODUCTION;
37+
}
38+
39+
/**
40+
* When adding files to the below array:
41+
* - `source` and `destination` paths must be relative to the project root folder
42+
* - `environment` key will indicate on what environments the file will be copied
43+
*/
44+
$files = [
45+
[
46+
'source' => 'config/autoload/local.php.dist',
47+
'destination' => 'config/autoload/local.php',
48+
'environment' => [ENVIRONMENT_DEVELOPMENT, ENVIRONMENT_PRODUCTION],
49+
],
50+
[
51+
'source' => 'vendor/dotkernel/dot-mail/config/mail.global.php.dist',
52+
'destination' => 'config/autoload/mail.global.php',
53+
'environment' => [ENVIRONMENT_DEVELOPMENT, ENVIRONMENT_PRODUCTION],
54+
],
55+
];
56+
57+
echo "Using environment setting: " . getEnvironment() . PHP_EOL;
58+
59+
array_walk($files, 'copyFile');

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"dotkernel/dot-cli": "^3.9",
5151
"dotkernel/dot-data-fixtures": "^1.4.0",
5252
"dotkernel/dot-dependency-injection": "^1.2",
53-
"dotkernel/dot-errorhandler": "^4.0.0",
53+
"dotkernel/dot-log": "4.0.4",
5454
"dotkernel/dot-mail": "^5.3.0",
5555
"dotkernel/dot-twigrenderer": "3.6.0",
5656
"laminas/laminas-component-installer": "^3.5",
@@ -79,8 +79,7 @@
7979
"Core\\App\\": "src/Core/src/App/src",
8080
"Core\\Security\\": "src/Core/src/Security/src",
8181
"Core\\Setting\\": "src/Core/src/Setting/src",
82-
"Core\\User\\": "src/Core/src/User/src",
83-
"Core\\NotificationSystem\\": "src/Core/src/NotificationSystem/src"
82+
"Core\\User\\": "src/Core/src/User/src"
8483
}
8584
},
8685
"autoload-dev": {
@@ -89,6 +88,9 @@
8988
}
9089
},
9190
"scripts": {
91+
"post-update-cmd": [
92+
"php bin/composer-post-install-script.php"
93+
],
9294
"check": [
9395
"@cs-check",
9496
"@test",

config/autoload/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
local.php
22
*.local.php
3-
mail.global.php
3+

config/autoload/local.php.dist

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ $baseUrl = 'http://localhost:8080';
1313

1414
$databases = [
1515
'default' => [
16-
'host' => '',
17-
'dbname' => '',
16+
'host' => 'localhost',
17+
'dbname' => 'dotkernel',
1818
'user' => '',
1919
'password' => '',
20-
'port' => ,
20+
'port' => 3306,
2121
'driver' => 'pdo_mysql',
2222
'charset' => 'utf8mb4',
2323
'collate' => 'utf8mb4_general_ci',
@@ -46,4 +46,4 @@ return [
4646
'eof' => "\n",
4747
],
4848
],
49-
];
49+
];

config/autoload/log.local.php.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ return [
2323
],
2424
],
2525
];
26+

config/autoload/mail.global.php.dist

Lines changed: 0 additions & 80 deletions
This file was deleted.

config/config.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
// Dotkernel packages
2727
Dot\Log\ConfigProvider::class,
2828
Dot\Cli\ConfigProvider::class,
29-
Dot\ErrorHandler\ConfigProvider::class,
3029
Dot\DataFixtures\ConfigProvider::class,
3130
Dot\DependencyInjection\ConfigProvider::class,
3231
Dot\Mail\ConfigProvider::class,
@@ -39,7 +38,6 @@
3938
Core\Security\ConfigProvider::class,
4039
Core\Setting\ConfigProvider::class,
4140
Core\User\ConfigProvider::class,
42-
Core\NotificationSystem\ConfigProvider::class,
4341

4442
// Load application config in a pre-defined order in such a way that local settings
4543
// overwrite global settings. (Loaded as first to last):

config/pipeline.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
declare(strict_types=1);
44

5-
use Dot\ErrorHandler\ErrorHandlerInterface;
65
use Mezzio\Application;
76
use Mezzio\MiddlewareFactory;
87
use Psr\Container\ContainerInterface;
@@ -14,7 +13,6 @@
1413
return function (Application $app, MiddlewareFactory $factory, ContainerInterface $container): void {
1514
// The error handler should be the first (most outer) middleware to catch
1615
// all Exceptions.
17-
$app->pipe(ErrorHandlerInterface::class);
1816

1917
// Pipe more middleware here that you want to execute on every request:
2018
// - bootstrapping

src/App/ConfigProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function getTemplates(): array
4949
{
5050
return [
5151
'paths' => [
52-
'notification-email' => [__DIR__ . '/../../templates'],
52+
'notification-email' => [__DIR__ . '/templates'],
5353
],
5454
];
5555
}

0 commit comments

Comments
 (0)