I'm trying to make a craft module, which sends a mail to the admin whenever a new user registers.
Somehow I'm not able to get this work, anyone knows how to solve this? The module is not able to send an email.
I used the command line craft commands to setup the structure of this module.
the module is called user registration mails
<?php
namespace modules\userregistrationmails;
use Craft;
use yii\base\Module as BaseModule;
use yii\base\Event;
use craft\services\Users;
use craft\events\UserEvent;
use craft\events\RegisterTemplateRootsEvent;
use craft\events\TemplateEvent;
use craft\i18n\PhpMessageSource;
use craft\web\View;
use yii\base\InvalidConfigException;
use craft\mail\Message;
use craft\mail\Mailer;
use yii\mail\MailEvent;
/**
* user-registration-mails module
*
* @method static Module getInstance()
*/
class Module extends BaseModule
{
public function init()
{
Craft::setAlias('@modules/userregistrationmails', __DIR__);
// Set the controllerNamespace based on whether this is a console or web request
if (Craft::$app->request->isConsoleRequest) {
$this->controllerNamespace = 'modules\\userregistrationmails\\console\\controllers';
} else {
$this->controllerNamespace = 'modules\\userregistrationmails\\controllers';
}
parent::init();
// Defer most setup tasks until Craft is fully initialized
Craft::$app->onInit(function() {
$this->attachEventHandlers();
// ...
});
}
private function attachEventHandlers(): void
{
Event::on(
Users::class,
Users::EVENT_BEFORE_ACTIVATE_USER,
function (UserEvent $event) {
$user = $event->user;
Craft::$app->getMailer()
->compose()
->setTo('[email protected]')
->setSubject('New User')
->setHtmlBody('New User: ' . $user->firstName . ' ' . $user->LastName)
->send();
}
);
}
}
logs:
2023-03-12 08:36:07 [web.INFO] [yii\db\Connection::open] Opening DB connection: mysql:host=db;dbname=db;port=3306 {"memory":1918440}
2023-03-12 08:36:07 [web.INFO] [yii\web\Session::open] Session started {"memory":4463832}
2023-03-12 08:36:07 [web.INFO] [nystudio107\twigfield\Twigfield::bootstrap] Twigfield module bootstrapped {"memory":4612280}
2023-03-12 08:36:07 [web.INFO] [modules\saveuserandsendmailmodule\SaveUserAndSendMailModule::init] save user and send mail module loaded {"memory":4713800}
2023-03-12 08:36:07 [web.INFO] [modules\afterprocesswebhookmodule\AfterProcessWebhookModule::init] afterProcessWebhook module loaded {"memory":4735280}
2023-03-12 08:36:07 [web.INFO] [homm\hommxmlsitemap\HOMMXMLSitemap::init] HOMM XML Sitemap plugin loaded {"memory":6438704}
2023-03-12 08:36:07 [web.INFO] [application] Request context:
$_GET = [
'p' => 'admin/actions/users/session-info'
'site' => 'default'
'dontExtendSession' => '1'
]
$_POST = []
$_COOKIE = [
'efd04dd08ddd9163864dcf0165762839_username' => '1d8ae463c52d3a45522adc09626ea8dd6ae8b81367efb6feb5e76b8381d0cef2a:2:{i:0;s:41:\"efd04dd08ddd9163864dcf0165762839_username\";i:1;s:5:\"admin\";}'
'__stripe_mid' => 'e560887f-80e9-4cf2-98ce-53c02e228361d29cfb'
'CraftSessionId' => '555e7985a48398f52b3cfa693c8a9273'
'CRAFT_CSRF_TOKEN' => '••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••'
]
$_FILES = []
$_SERVER = [
'DEPLOY_NAME' => 'local'
'DDEV_WEBSERVER_TYPE' => 'nginx-fpm'
'npm_config_cache' => '/mnt/ddev-global-cache/npm'
'IS_DDEV_PROJECT' => 'true'
'PHP_DEFAULT_VERSION' => '8.0'
'HOSTNAME' => 'scoops-web'
'MH_SMTP_BIND_ADDR' => '127.0.0.1:1025'
'SSH_AUTH_SOCK' => '/home/.ssh-agent/socket'
'NODE_EXTRA_CA_CERTS' => '/mnt/ddev-global-cache/mkcert/rootCA.pem'
'DOCKER_IP' => '127.0.0.1'
'PGPASSWORD' => 'db'
'DRUSH_ALLOW_XDEBUG' => '1'
'MYSQL_PWD' => 'db'
'DDEV_DOCROOT' => 'web'
'PWD' => '/var/www/html'
'PLATFORMSH_CLI_UPDATES_CHECK' => '0'
'DDEV_FILES_DIR' => ''
'APACHE_SITE_TEMPLATE' => '/etc/apache2/apache-site.conf'
'PHP_INI' => '/etc/php/8.0/fpm/php.ini'
'GOARCH' => 'amd64'
'DDEV_VERSION' => 'v1.21.4'
'TZ' => ''
'HTTPS_EXPOSE' => '443:80,8026:8025'
'DDEV_PRIMARY_URL' => 'https://scoops.ddev.site'
'LINES' => '30'
'DDEV_SITENAME' => 'scoops'
'HOME' => '/home/arnemichiels'
'DRUSH_OPTIONS_URI' => 'https://scoops.ddev.site'
'LANG' => 'C.UTF-8'
'COLUMNS' => '120'
'PGUSER' => 'db'
'TERMINUS_CACHE_DIR' => '/mnt/ddev-global-cache/terminus/cache'
'DDEV_ROUTER_HTTP_PORT' => '80'
'COMPOSER_PROCESS_TIMEOUT' => '2000'
'NGINX_SITE_TEMPLATE' => '/etc/nginx/nginx-site.conf'
'HTTP_EXPOSE' => '80:80,8025:8025'
'DDEV_PHP_VERSION' => '8.0'
'DDEV_TLD' => 'ddev.site'
'DDEV_HOSTNAME' => 'scoops.ddev.site'
'DDEV_PROJECT' => 'scoops'
'VIRTUAL_HOST' => 'scoops.ddev.site'
'TERM' => 'xterm'
'USER' => 'arnemichiels'
'MYSQL_HISTFILE' => '/mnt/ddev-global-cache/mysqlhistory/scoops-web/mysql_history'
'CAROOT' => '/mnt/ddev-global-cache/mkcert'
'SHLVL' => '0'
'COMPOSER_ALLOW_SUPERUSER' => '1'
'BASH_ENV' => '/etc/bash.nointeractive.bashrc'
'DDEV_DATABASE' => 'mariadb:10.4'
'PGDATABASE' => 'db'
'XHPROF_OUTPUT_DIR' => '/tmp/xhprof'
'COMPOSER_CACHE_DIR' => '/mnt/ddev-global-cache/composer'
'DDEV_XDEBUG_ENABLED' => 'false'
'PGHOST' => 'db'
'DDEV_COMPOSER_ROOT' => '/var/www/html'
'DOCROOT' => 'web'
'TERMINUS_HIDE_UPDATE_MESSAGE' => '1'
'PATH' => '~/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/www/html/vendor/bin:/var/www/html/bin:/var/www/html/vendor/bin'
'HOST_DOCKER_INTERNAL_IP' => ''
'DEBIAN_FRONTEND' => 'noninteractive'
'DDEV_PROJECT_TYPE' => 'craftcms'
'DDEV_ROUTER_HTTPS_PORT' => '443'
'GOOS' => 'linux'
'SUPERVISOR_ENABLED' => '1'
'SUPERVISOR_SERVER_URL' => 'unix:///var/run/supervisor.sock'
'SUPERVISOR_PROCESS_NAME' => 'php-fpm'
'SUPERVISOR_GROUP_NAME' => 'php-fpm'
'HTTP_COOKIE' => 'efd04dd08ddd9163864dcf0165762839_username=1d8ae463c52d3a45522adc09626ea8dd6ae8b81367efb6feb5e76b8381d0cef2a%3A2%3A%7Bi%3A0%3Bs%3A41%3A%22efd04dd08ddd9163864dcf0165762839_username%22%3Bi%3A1%3Bs%3A5%3A%22admin%22%3B%7D; __stripe_mid=e560887f-80e9-4cf2-98ce-53c02e228361d29cfb; CraftSessionId=555e7985a48398f52b3cfa693c8a9273; CRAFT_CSRF_TOKEN=fa2a4edd1e5a0728268bbd16e327a95dbdf8cf57323423b9cb3c7c2f8a9d986ea%3A2%3A%7Bi%3A0%3Bs%3A16%3A%22CRAFT_CSRF_TOKEN%22%3Bi%3A1%3Bs%3A40%3A%223ePayfcVtp88RIgJ7GkRQnVQFQ9_c2cMGPXHJutn%22%3B%7D'
'HTTP_ACCEPT_LANGUAGE' => 'nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7'
'HTTP_ACCEPT_ENCODING' => 'gzip, deflate, br'
'HTTP_REFERER' => 'https://scoops.ddev.site/admin/utilities/clear-caches?site=default'
'HTTP_SEC_FETCH_DEST' => 'empty'
'HTTP_SEC_FETCH_MODE' => 'cors'
'HTTP_SEC_FETCH_SITE' => 'same-origin'
'HTTP_SEC_CH_UA_PLATFORM' => '\"Windows\"'
'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36'
'HTTP_SEC_CH_UA_MOBILE' => '?0'
'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest'
'HTTP_ACCEPT' => 'application/json, text/javascript, */*; q=0.01'
'HTTP_SEC_CH_UA' => '\"Google Chrome\";v=\"111\", \"Not(A:Brand\";v=\"8\", \"Chromium\";v=\"111\"'
'HTTP_X_FORWARDED_PORT' => '443'
'HTTP_X_FORWARDED_SSL' => 'on'
'HTTP_X_FORWARDED_PROTO' => 'https'
'HTTP_X_FORWARDED_FOR' => '172.18.0.1'
'HTTP_X_REAL_IP' => '172.18.0.1'
'HTTP_CONNECTION' => 'close'
'HTTP_HOST' => 'scoops.ddev.site'
'HTTPS' => 'on'
'REDIRECT_STATUS' => '200'
'SERVER_NAME' => 'scoops.ddev.site'
'SERVER_PORT' => '80'
'SERVER_ADDR' => '172.18.0.3'
'REMOTE_PORT' => '39800'
'REMOTE_ADDR' => '172.18.0.6'
'SERVER_SOFTWARE' => 'nginx/1.22.1'
'GATEWAY_INTERFACE' => 'CGI/1.1'
'REQUEST_SCHEME' => 'http'
'SERVER_PROTOCOL' => 'HTTP/1.1'
'DOCUMENT_ROOT' => '/var/www/html/web'
'DOCUMENT_URI' => '/index.php'
'REQUEST_URI' => '/index.php?p=admin%2Factions%2Fusers%2Fsession-info&site=default&dontExtendSession=1'
'CONTENT_LENGTH' => ''
'CONTENT_TYPE' => ''
'REQUEST_METHOD' => 'GET'
'QUERY_STRING' => 'p=admin%2Factions%2Fusers%2Fsession-info&site=default&dontExtendSession=1'
'SCRIPT_NAME' => '/index.php'
'SCRIPT_FILENAME' => '/var/www/html/web/index.php'
'FCGI_ROLE' => 'RESPONDER'
'PHP_SELF' => '/index.php'
'REQUEST_TIME_FLOAT' => 1678610167.7182
'REQUEST_TIME' => 1678610167
'CRAFT_APP_ID' => 'CraftCMS--47a85736-3be8-4c6f-ac80-e3702fe0435c'
'CRAFT_ENVIRONMENT' => 'dev'
'CRAFT_SECURITY_KEY' => '••••••••••••••••••••••••••••••••'
'CRAFT_DB_DRIVER' => 'mysql'
'CRAFT_DB_SERVER' => 'db'
'CRAFT_DB_PORT' => '3306'
'CRAFT_DB_DATABASE' => 'db'
'CRAFT_DB_USER' => 'db'
'CRAFT_DB_PASSWORD' => '••'
'CRAFT_DB_SCHEMA' => ''
'CRAFT_DB_TABLE_PREFIX' => ''
'CP_TRIGGER' => 'admin'
'PRIMARY_SITE_URL' => 'https://scoops.ddev.site'
'ASSET_BASE_URL' => 'http://localhost/scoopsardooie/web/uploads'
'ASSET_BASE_PATH' => 'uploads'
'MAILHOG_SMTP_PORT' => '1025'
'MAILHOG_SMTP_HOSTNAME' => '127.0.0.1'
]
$_SESSION = [
'668ef524e696f2df1a1d0792428f07eb__flash' => [
'notice' => -1
]
'notice' => 'Gebruiker geregistreerd.'
]
2023-03-12 08:37:08 [web.INFO] [yii\db\Connection::open] Opening DB connection: mysql:host=db;dbname=db;port=3306 {"memory":1918440}
2023-03-12 08:37:08 [web.INFO] [yii\web\Session::open] Session started {"memory":4463832}
2023-03-12 08:37:08 [web.INFO] [nystudio107\twigfield\Twigfield::bootstrap] Twigfield module bootstrapped {"memory":4612280}
2023-03-12 08:37:08 [web.INFO] [modules\saveuserandsendmailmodule\SaveUserAndSendMailModule::init] save user and send mail module loaded {"memory":4713800}
2023-03-12 08:37:08 [web.INFO] [modules\afterprocesswebhookmodule\AfterProcessWebhookModule::init] afterProcessWebhook module loaded {"memory":4735280}
2023-03-12 08:37:08 [web.INFO] [homm\hommxmlsitemap\HOMMXMLSitemap::init] HOMM XML Sitemap plugin loaded {"memory":6438704}
2023-03-12 08:37:08 [web.INFO] [application] Request context:
$_GET = [
'p' => 'admin/actions/users/session-info'
'site' => 'default'
'dontExtendSession' => '1'
]
$_POST = []
$_COOKIE = [
'efd04dd08ddd9163864dcf0165762839_username' => '1d8ae463c52d3a45522adc09626ea8dd6ae8b81367efb6feb5e76b8381d0cef2a:2:{i:0;s:41:\"efd04dd08ddd9163864dcf0165762839_username\";i:1;s:5:\"admin\";}'
'__stripe_mid' => 'e560887f-80e9-4cf2-98ce-53c02e228361d29cfb'
'CraftSessionId' => '555e7985a48398f52b3cfa693c8a9273'
'CRAFT_CSRF_TOKEN' => '••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••'
]
$_FILES = []
$_SERVER = [
'DEPLOY_NAME' => 'local'
'DDEV_WEBSERVER_TYPE' => 'nginx-fpm'
'npm_config_cache' => '/mnt/ddev-global-cache/npm'
'IS_DDEV_PROJECT' => 'true'
'PHP_DEFAULT_VERSION' => '8.0'
'HOSTNAME' => 'scoops-web'
'MH_SMTP_BIND_ADDR' => '127.0.0.1:1025'
'SSH_AUTH_SOCK' => '/home/.ssh-agent/socket'
'NODE_EXTRA_CA_CERTS' => '/mnt/ddev-global-cache/mkcert/rootCA.pem'
'DOCKER_IP' => '127.0.0.1'
'PGPASSWORD' => 'db'
'DRUSH_ALLOW_XDEBUG' => '1'
'MYSQL_PWD' => 'db'
'DDEV_DOCROOT' => 'web'
'PWD' => '/var/www/html'
'PLATFORMSH_CLI_UPDATES_CHECK' => '0'
'DDEV_FILES_DIR' => ''
'APACHE_SITE_TEMPLATE' => '/etc/apache2/apache-site.conf'
'PHP_INI' => '/etc/php/8.0/fpm/php.ini'
'GOARCH' => 'amd64'
'DDEV_VERSION' => 'v1.21.4'
'TZ' => ''
'HTTPS_EXPOSE' => '443:80,8026:8025'
'DDEV_PRIMARY_URL' => 'https://scoops.ddev.site'
'LINES' => '30'
'DDEV_SITENAME' => 'scoops'
'HOME' => '/home/arnemichiels'
'DRUSH_OPTIONS_URI' => 'https://scoops.ddev.site'
'LANG' => 'C.UTF-8'
'COLUMNS' => '120'
'PGUSER' => 'db'
'TERMINUS_CACHE_DIR' => '/mnt/ddev-global-cache/terminus/cache'
'DDEV_ROUTER_HTTP_PORT' => '80'
'COMPOSER_PROCESS_TIMEOUT' => '2000'
'NGINX_SITE_TEMPLATE' => '/etc/nginx/nginx-site.conf'
'HTTP_EXPOSE' => '80:80,8025:8025'
'DDEV_PHP_VERSION' => '8.0'
'DDEV_TLD' => 'ddev.site'
'DDEV_HOSTNAME' => 'scoops.ddev.site'
'DDEV_PROJECT' => 'scoops'
'VIRTUAL_HOST' => 'scoops.ddev.site'
'TERM' => 'xterm'
'USER' => 'arnemichiels'
'MYSQL_HISTFILE' => '/mnt/ddev-global-cache/mysqlhistory/scoops-web/mysql_history'
'CAROOT' => '/mnt/ddev-global-cache/mkcert'
'SHLVL' => '0'
'COMPOSER_ALLOW_SUPERUSER' => '1'
'BASH_ENV' => '/etc/bash.nointeractive.bashrc'
'DDEV_DATABASE' => 'mariadb:10.4'
'PGDATABASE' => 'db'
'XHPROF_OUTPUT_DIR' => '/tmp/xhprof'
'COMPOSER_CACHE_DIR' => '/mnt/ddev-global-cache/composer'
'DDEV_XDEBUG_ENABLED' => 'false'
'PGHOST' => 'db'
'DDEV_COMPOSER_ROOT' => '/var/www/html'
'DOCROOT' => 'web'
'TERMINUS_HIDE_UPDATE_MESSAGE' => '1'
'PATH' => '~/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/www/html/vendor/bin:/var/www/html/bin:/var/www/html/vendor/bin'
'HOST_DOCKER_INTERNAL_IP' => ''
'DEBIAN_FRONTEND' => 'noninteractive'
'DDEV_PROJECT_TYPE' => 'craftcms'
'DDEV_ROUTER_HTTPS_PORT' => '443'
'GOOS' => 'linux'
'SUPERVISOR_ENABLED' => '1'
'SUPERVISOR_SERVER_URL' => 'unix:///var/run/supervisor.sock'
'SUPERVISOR_PROCESS_NAME' => 'php-fpm'
'SUPERVISOR_GROUP_NAME' => 'php-fpm'
'HTTP_COOKIE' => 'efd04dd08ddd9163864dcf0165762839_username=1d8ae463c52d3a45522adc09626ea8dd6ae8b81367efb6feb5e76b8381d0cef2a%3A2%3A%7Bi%3A0%3Bs%3A41%3A%22efd04dd08ddd9163864dcf0165762839_username%22%3Bi%3A1%3Bs%3A5%3A%22admin%22%3B%7D; __stripe_mid=e560887f-80e9-4cf2-98ce-53c02e228361d29cfb; CraftSessionId=555e7985a48398f52b3cfa693c8a9273; CRAFT_CSRF_TOKEN=fa2a4edd1e5a0728268bbd16e327a95dbdf8cf57323423b9cb3c7c2f8a9d986ea%3A2%3A%7Bi%3A0%3Bs%3A16%3A%22CRAFT_CSRF_TOKEN%22%3Bi%3A1%3Bs%3A40%3A%223ePayfcVtp88RIgJ7GkRQnVQFQ9_c2cMGPXHJutn%22%3B%7D'
'HTTP_ACCEPT_LANGUAGE' => 'nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7'
'HTTP_ACCEPT_ENCODING' => 'gzip, deflate, br'
'HTTP_REFERER' => 'https://scoops.ddev.site/admin/utilities/clear-caches?site=default'
'HTTP_SEC_FETCH_DEST' => 'empty'
'HTTP_SEC_FETCH_MODE' => 'cors'
'HTTP_SEC_FETCH_SITE' => 'same-origin'
'HTTP_SEC_CH_UA_PLATFORM' => '\"Windows\"'
'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36'
'HTTP_SEC_CH_UA_MOBILE' => '?0'
'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest'
'HTTP_ACCEPT' => 'application/json, text/javascript, */*; q=0.01'
'HTTP_SEC_CH_UA' => '\"Google Chrome\";v=\"111\", \"Not(A:Brand\";v=\"8\", \"Chromium\";v=\"111\"'
'HTTP_X_FORWARDED_PORT' => '443'
'HTTP_X_FORWARDED_SSL' => 'on'
'HTTP_X_FORWARDED_PROTO' => 'https'
'HTTP_X_FORWARDED_FOR' => '172.18.0.1'
'HTTP_X_REAL_IP' => '172.18.0.1'
'HTTP_CONNECTION' => 'close'
'HTTP_HOST' => 'scoops.ddev.site'
'HTTPS' => 'on'
'REDIRECT_STATUS' => '200'
'SERVER_NAME' => 'scoops.ddev.site'
'SERVER_PORT' => '80'
'SERVER_ADDR' => '172.18.0.3'
'REMOTE_PORT' => '52952'
'REMOTE_ADDR' => '172.18.0.6'
'SERVER_SOFTWARE' => 'nginx/1.22.1'
'GATEWAY_INTERFACE' => 'CGI/1.1'
'REQUEST_SCHEME' => 'http'
'SERVER_PROTOCOL' => 'HTTP/1.1'
'DOCUMENT_ROOT' => '/var/www/html/web'
'DOCUMENT_URI' => '/index.php'
'REQUEST_URI' => '/index.php?p=admin%2Factions%2Fusers%2Fsession-info&site=default&dontExtendSession=1'
'CONTENT_LENGTH' => ''
'CONTENT_TYPE' => ''
'REQUEST_METHOD' => 'GET'
'QUERY_STRING' => 'p=admin%2Factions%2Fusers%2Fsession-info&site=default&dontExtendSession=1'
'SCRIPT_NAME' => '/index.php'
'SCRIPT_FILENAME' => '/var/www/html/web/index.php'
'FCGI_ROLE' => 'RESPONDER'
'PHP_SELF' => '/index.php'
'REQUEST_TIME_FLOAT' => 1678610228.707
'REQUEST_TIME' => 1678610228
'CRAFT_APP_ID' => 'CraftCMS--47a85736-3be8-4c6f-ac80-e3702fe0435c'
'CRAFT_ENVIRONMENT' => 'dev'
'CRAFT_SECURITY_KEY' => '••••••••••••••••••••••••••••••••'
'CRAFT_DB_DRIVER' => 'mysql'
'CRAFT_DB_SERVER' => 'db'
'CRAFT_DB_PORT' => '3306'
'CRAFT_DB_DATABASE' => 'db'
'CRAFT_DB_USER' => 'db'
'CRAFT_DB_PASSWORD' => '••'
'CRAFT_DB_SCHEMA' => ''
'CRAFT_DB_TABLE_PREFIX' => ''
'CP_TRIGGER' => 'admin'
'PRIMARY_SITE_URL' => 'https://scoops.ddev.site'
'ASSET_BASE_URL' => 'http://localhost/scoopsardooie/web/uploads'
'ASSET_BASE_PATH' => 'uploads'
'MAILHOG_SMTP_PORT' => '1025'
'MAILHOG_SMTP_HOSTNAME' => '127.0.0.1'
]
$_SESSION = [
'668ef524e696f2df1a1d0792428f07eb__flash' => [
'notice' => -1
]
'notice' => 'Gebruiker geregistreerd.'
]
app.php:
<?php
/**
* Yii Application Config
*
* Edit this file at your own risk!
*
* The array returned by this file will get merged with
* vendor/craftcms/cms/src/config/app.php and app.[web|console].php, when
* Craft's bootstrap script is defining the configuration for the entire
* application.
*
* You can define custom modules and system components, and even override the
* built-in system components.
*
* If you want to modify the application config for *only* web requests or
* *only* console requests, create an app.web.php or app.console.php file in
* your config/ folder, alongside this one.
*/
use craft\helpers\App;
use modules\usermails\Module;
use modules\userregistrationmails\Module as ModuleAlias;
return [
'id' => App::env('CRAFT_APP_ID') ?: 'CraftCMS',
'modules' => [
'save-user-and-send-mail-module' => [
'class' => \modules\saveuserandsendmailmodule\SaveUserAndSendMailModule::class,
],
'after-process-webhook-module' => [
'class' => \modules\afterprocesswebhookmodule\AfterProcessWebhookModule::class,
],
'user-registration-mails' => ModuleAlias::class,
],
'bootstrap' => ['save-user-and-send-mail-module', 'after-process-webhook-module', 'user-registration-mails'],
];
composer.json:
"autoload": {
"psr-4": {
"modules\\userRegistration\\": "modules/userRegistration/",
"modules\\saveuserandsendmailmodule\\": "modules/saveuserandsendmailmodule/src/",
"modules\\afterprocesswebhookmodule\\": "modules/afterprocesswebhookmodule/src/",
"modules\\usermails\\": "modules/user-mails/",
"modules\\userregistrationmails\\": "modules/user-registration-mails/"
}
},
modules structure:
modules/ --------user-registration-mails/ -------------------------------module.php