Skip to content

Commit 6c03609

Browse files
committed
Issue #16: Implemented core and sending email functionality
Signed-off-by: sergiu <[email protected]>
1 parent c56ae2b commit 6c03609

File tree

92 files changed

+6179
-49
lines changed

Some content is hidden

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

92 files changed

+6179
-49
lines changed

composer.json

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,23 @@
4444
},
4545
"require": {
4646
"php": "~8.2.0 || ~8.3.0 || ~8.4",
47+
"ext-sockets": "*",
48+
"clue/socket-raw": "^v1.6.0",
49+
"dotkernel/dot-cache": "^4.3",
4750
"dotkernel/dot-cli": "^3.9",
48-
"dotkernel/dot-errorhandler": "^4.2.1",
51+
"dotkernel/dot-data-fixtures": "^1.4.0",
52+
"dotkernel/dot-dependency-injection": "^1.2",
53+
"dotkernel/dot-errorhandler": "^4.0.0",
54+
"dotkernel/dot-mail": "^5.3.0",
55+
"dotkernel/dot-twigrenderer": "3.6.0",
4956
"laminas/laminas-component-installer": "^3.5",
5057
"laminas/laminas-config-aggregator": "^1.18",
5158
"mezzio/mezzio": "^3.20",
59+
"mezzio/mezzio-authentication-oauth2": "^2.11",
5260
"netglue/laminas-messenger": "^2.3.0",
61+
"ramsey/uuid": "^4.5.0",
62+
"ramsey/uuid-doctrine": "^2.1.0",
63+
"roave/psr-container-doctrine": "^5.2.2",
5364
"symfony/redis-messenger": "^v7.2.3"
5465
},
5566
"require-dev": {
@@ -63,7 +74,13 @@
6374
},
6475
"autoload": {
6576
"psr-4": {
66-
"Queue\\": "src/"
77+
"Queue\\": "src/",
78+
"Core\\Admin\\": "src/Core/src/Admin/src",
79+
"Core\\App\\": "src/Core/src/App/src",
80+
"Core\\Security\\": "src/Core/src/Security/src",
81+
"Core\\Setting\\": "src/Core/src/Setting/src",
82+
"Core\\User\\": "src/Core/src/User/src",
83+
"Core\\NotificationSystem\\": "src/Core/src/NotificationSystem/src"
6784
}
6885
},
6986
"autoload-dev": {

config/autoload/.gitignore

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

config/autoload/local.php.dist

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,41 @@
99

1010
declare(strict_types=1);
1111

12-
return [
12+
$baseUrl = 'http://localhost:8080';
13+
14+
$databases = [
15+
'default' => [
16+
'host' => '',
17+
'dbname' => '',
18+
'user' => '',
19+
'password' => '',
20+
'port' => ,
21+
'driver' => 'pdo_mysql',
22+
'charset' => 'utf8mb4',
23+
'collate' => 'utf8mb4_general_ci',
24+
],
25+
// you can add more database connections into this array
1326
];
27+
28+
return [
29+
'application' => [
30+
'name' => $app['name'] ?? '',
31+
'url' => $baseUrl,
32+
],
33+
'databases' => $databases,
34+
'doctrine' => [
35+
'connection' => [
36+
'orm_default' => [
37+
'params' => $databases['default'],
38+
],
39+
],
40+
],
41+
'notification' => [
42+
'server' => [
43+
'protocol' => '',
44+
'host' => '',
45+
'port' => '',
46+
'eof' => "\n",
47+
],
48+
],
49+
];
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
return [
6+
/**
7+
* Dotkernel mail module configuration
8+
* Note that many of these options can be set programmatically too, when sending mail messages actually that is
9+
* what you'll usually do, these configs provide just defaults and options that remain the same for all mails
10+
*/
11+
'dot_mail' => [
12+
//the key is the mail service name, this is the default one, which does not extend any configuration
13+
'default' => [
14+
//message configuration
15+
'message_options' => [
16+
//from email address of the email
17+
'from' => '',
18+
//from name to be displayed instead of from address
19+
'from_name' => '',
20+
//reply-to email address of the email
21+
'reply_to' => '',
22+
//replyTo name to be displayed instead of the address
23+
'reply_to_name' => '',
24+
//destination email address as string or a list of email addresses
25+
'to' => [],
26+
//copy destination addresses
27+
'cc' => [],
28+
//hidden copy destination addresses
29+
'bcc' => [],
30+
//email subject
31+
'subject' => '',
32+
//body options - content can be plain text, HTML
33+
'body' => [
34+
'content' => '',
35+
'charset' => 'utf-8',
36+
],
37+
//attachments config
38+
'attachments' => [
39+
'files' => [],
40+
'dir' => [
41+
'iterate' => false,
42+
'path' => 'data/mail/attachments',
43+
'recursive' => false,
44+
],
45+
],
46+
],
47+
/**
48+
* the mail transport to use can be any class implementing
49+
* Symfony\Component\Mailer\Transport\TransportInterface
50+
*
51+
* for standard mail transports, you can use these aliases:
52+
* - sendmail => Symfony\Component\Mailer\Transport\SendmailTransport
53+
* - esmtp => Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport
54+
*
55+
* defaults to sendmail
56+
**/
57+
'transport' => 'esmtp',
58+
//options that will be used only if esmtp adapter is used
59+
'smtp_options' => [
60+
//hostname or IP address of the mail server
61+
'host' => '',
62+
//port of the mail server - 587 or 465 for secure connections
63+
'port' => 587,
64+
'connection_config' => [
65+
//the smtp authentication identity
66+
'username' => '',
67+
//the smtp authentication credential
68+
'password' => '',
69+
//to disable auto_tls set tls key to false
70+
//it's not recommended to disable TLS while connecting to an SMTP server
71+
'tls' => null,
72+
],
73+
],
74+
],
75+
// option to log the SENT emails
76+
'log' => [
77+
'sent' => getcwd() . '/log/mail/sent.log',
78+
],
79+
],
80+
];
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+
use Dot\Twig\Extension\DateExtension;
6+
use Dot\Twig\Extension\TranslationExtension;
7+
use Laminas\ServiceManager\Factory\InvokableFactory;
8+
use Mezzio\Template\TemplateRendererInterface;
9+
use Mezzio\Twig\TwigEnvironmentFactory;
10+
use Mezzio\Twig\TwigRendererFactory;
11+
use Twig\Environment;
12+
13+
return [
14+
'dependencies' => [
15+
'factories' => [
16+
DateExtension::class => InvokableFactory::class,
17+
Environment::class => TwigEnvironmentFactory::class,
18+
TemplateRendererInterface::class => TwigRendererFactory::class,
19+
TranslationExtension::class => InvokableFactory::class,
20+
],
21+
],
22+
'debug' => false,
23+
'templates' => [
24+
'extension' => 'html.twig',
25+
],
26+
'twig' => [
27+
'assets_url' => '/',
28+
'assets_version' => null,
29+
'auto_reload' => true,
30+
'autoescape' => 'html',
31+
'cache_dir' => 'data/cache/twig',
32+
'extensions' => [
33+
DateExtension::class,
34+
TranslationExtension::class,
35+
],
36+
'globals' => [
37+
'appName' => $app['name'] ?? '',
38+
],
39+
'optimizations' => -1,
40+
'runtime_loaders' => [],
41+
// 'timezone' => '',
42+
],
43+
];

config/config.php

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,31 @@
1515
$aggregator = new ConfigAggregator([
1616
// Include cache configuration
1717
new ArrayProvider($cacheConfig),
18-
\Mezzio\ConfigProvider::class,
19-
\Dot\ErrorHandler\ConfigProvider::class,
20-
\Dot\Log\ConfigProvider::class,
21-
\Dot\Cli\ConfigProvider::class,
22-
\Netglue\PsrContainer\Messenger\ConfigProvider::class,
18+
Mezzio\ConfigProvider::class,
19+
Mezzio\Twig\ConfigProvider::class,
20+
Netglue\PsrContainer\Messenger\ConfigProvider::class,
2321

2422
// Default App module config
25-
\Queue\App\ConfigProvider::class,
26-
\Queue\Swoole\ConfigProvider::class,
23+
Queue\App\ConfigProvider::class,
24+
Queue\Swoole\ConfigProvider::class,
25+
26+
// Dotkernel packages
27+
Dot\Log\ConfigProvider::class,
28+
Dot\Cli\ConfigProvider::class,
29+
Dot\ErrorHandler\ConfigProvider::class,
30+
Dot\DataFixtures\ConfigProvider::class,
31+
Dot\DependencyInjection\ConfigProvider::class,
32+
Dot\Mail\ConfigProvider::class,
33+
Dot\Twig\ConfigProvider::class,
34+
Dot\Cache\ConfigProvider::class,
35+
36+
// Core modules
37+
Core\Admin\ConfigProvider::class,
38+
Core\App\ConfigProvider::class,
39+
Core\Security\ConfigProvider::class,
40+
Core\Setting\ConfigProvider::class,
41+
Core\User\ConfigProvider::class,
42+
Core\NotificationSystem\ConfigProvider::class,
2743

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

phpcs.xml.dist renamed to phpcs.xml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,10 @@
1919
<exclude-pattern>config/routes.php</exclude-pattern>
2020

2121
<!-- Include all rules from the Laminas Coding Standard -->
22-
<rule ref="LaminasCodingStandard"/>
23-
24-
<rule ref="Squiz.Classes.ClassFileName.NoMatch">
25-
<exclude-pattern>src/ConfigProvider.*.php</exclude-pattern>
26-
</rule>
27-
28-
<rule ref="PSR12.Files.FileHeader.IncorrectOrder">
22+
<rule ref="LaminasCodingStandard">
23+
<!-- Exclude rule -->
24+
<exclude name="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName" />
25+
<exclude-pattern>src/Core/src/App/src/Migration/*</exclude-pattern>
2926
<exclude-pattern>config/pipeline.php</exclude-pattern>
30-
<exclude-pattern>src/MezzioInstaller/Resources/config/routes-*.php</exclude-pattern>
3127
</rule>
3228
</ruleset>

phpstan.neon

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,3 @@ parameters:
77
- src
88
- test
99
treatPhpDocTypesAsCertain: false
10-
ignoreErrors:
11-
- '#Constant Queue\\Swoole\\Command\\StartCommand::PROGRAMMATIC_CONFIG_FILES is unused#'

src/App/ConfigProvider.php

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

55
namespace Queue\App;
66

7+
use Dot\DependencyInjection\Factory\AttributedServiceFactory;
78
use Netglue\PsrContainer\Messenger\Container\MessageBusStaticFactory;
89
use Netglue\PsrContainer\Messenger\Container\Middleware\BusNameStampMiddlewareStaticFactory;
910
use Netglue\PsrContainer\Messenger\Container\Middleware\MessageHandlerMiddlewareStaticFactory;
1011
use Netglue\PsrContainer\Messenger\Container\Middleware\MessageSenderMiddlewareStaticFactory;
1112
use Netglue\PsrContainer\Messenger\HandlerLocator\OneToManyFqcnContainerHandlerLocator;
1213
use Queue\App\Message\ExampleMessage;
1314
use Queue\App\Message\ExampleMessageHandler;
14-
use Queue\App\Message\ExampleMessageHandlerFactory;
1515
use Symfony\Component\Messenger\MessageBusInterface;
1616

1717
class ConfigProvider
@@ -25,6 +25,7 @@ public function __invoke(): array
2525
'buses' => $this->busConfig(),
2626
],
2727
],
28+
'templates' => $this->getTemplates(),
2829
];
2930
}
3031

@@ -36,14 +37,23 @@ private function getDependencies(): array
3637
"message_bus_stamp_middleware" => [BusNameStampMiddlewareStaticFactory::class, "message_bus"],
3738
"message_bus_sender_middleware" => [MessageSenderMiddlewareStaticFactory::class, "message_bus"],
3839
"message_bus_handler_middleware" => [MessageHandlerMiddlewareStaticFactory::class, "message_bus"],
39-
ExampleMessageHandler::class => ExampleMessageHandlerFactory::class,
40+
ExampleMessageHandler::class => AttributedServiceFactory::class,
4041
],
4142
"aliases" => [
4243
MessageBusInterface::class => "message_bus",
4344
],
4445
];
4546
}
4647

48+
public function getTemplates(): array
49+
{
50+
return [
51+
'paths' => [
52+
'notification-email' => [__DIR__ . '/../../templates'],
53+
],
54+
];
55+
}
56+
4757
private function busConfig(): array
4858
{
4959
return [

0 commit comments

Comments
 (0)