Deviations from the standard Symfony Framework

Custom directory structure

Mautic 使用的目录路径与 Symfony 中常见的路径不同,这是为了使其易于分发。

Directory

Description

app/bundles/

与 Core 一起分发的 Symfony bundles

app/config/

Symfony 配置文件

app/middlewares/

请参阅 Middlewares

app/migrations/

Doctrine migrations,用于更新 Core 的数据库 schema

bin/console/

用于执行 Symfony/Mautic 命令

media/

包含合并和压缩的生产环境资源以及默认图像

plugins/

Mautic 插件,作为 Symfony bundles

themes/

Mautic 主题

themes/system

包含针对 Mautic Core 模板的自定义覆盖

translations/

Mautic 翻译文件,由 Mautic 的自定义 components/translator:Translator 使用

var/

包含临时文件,例如日志和 Symfony 的缓存

vendor/

包含 Composer 安装的依赖项

Mautic 主要使用 Symfony 的 2.x/3.x bundle 结构,用于 Core bundles(位于 app\bundles\)以及自定义插件(位于 plugins\)。有关这些内容的更多信息,请参阅 here

PHP everything

Mautic 最初是用 PHP 编写的。由于当时不熟悉 YAML 和 Twig,因此主要避免使用。这就是为什么 Mautic 默认使用 Symfony 的 PHP 模板引擎以及基于 PHP 的配置。

Note

Symfony 已经弃用了其 PHP 模板引擎,并在 Symfony 5 中将其移除。Twig 正在逐渐引入以替换 PHP 模板。

PHP 配置的目标是在 bundle 中的一个地方定义路由、服务、菜单、参数等,而不是在应用程序代码中搜索注释。Symfony 的 PHP 配置用于注册服务、参数、路由等,也比较冗长。因此,Mautic 提供了一个自定义配置框架,通过 \Mautic\CoreBundle\DependencyInjection\MauticCoreExtension 和各种监听器实现。

Custom configuration

Mautic 构建了自己的配置系统,服务可以通过 Symfony 参数或 \Mautic\CoreBundle\Helper\CoreParametersHelper 访问该系统。默认情况下,Mautic 将配置键/值对写入到 app/config/local.php 文件中。

Note

请使用 Mautic 原生的配置参数管理方式,尽管您也可以定义和使用 Symfony 参数,如果您需要的话。

Mautic 3 introduced support for Symfony’s environment variables. Note that not all bundles support environment variables for Symfony’s configuration so take this into account before using third party bundles. You can sometimes implement workarounds by using custom proxy or delegation services. For example, see \Mautic\EmailBundle\Swiftmailer\Spool\DelegatingSpool.

Included commands

Mautic includes its own commands in addition to commands defined by Symfony and Symfony bundles such as the makers bundle.

Running ./bin/console without any arguments outputs a list of available commands.

Note

Some commands are only available in the development or test environments.

Autowired services

Mautic doesn’t auto-wire native services other than Symfony commands and controllers.

Service scope

Services are public by default to have backwards compatibility with Mautic 3 and Symfony 3. You can change the scope of your service by setting public to false when defining the service in the Plugin’s Config/config.php.

Support for entity annotations

By default, Mautic uses Doctrine’s PHP driver instead of annotations which requires a public static function loadMetadata(ORM\ClassMetadata $metadata) method. However, Plugins can use annotations if desired but should use only annotations or only PHP loadMetadata. A Plugin can’t use a mix of both. See plugins/data:Entities and schema for more information.

Firewalls and User access management

app/config/security.php lists Mautic’s firewalls. For the most part, Mautic uses Symfony’s standard way of registering firewalls and authentication with a means for Plugins to hook into the authentication process through listeners to the UserEvents::USER_PRE_AUTHENTICATION and UserEvents::USER_FORM_AUTHENTICATION events.

Mautic has its own permission system based on bitwise permissions and thus doesn’t leverage Symfony voters.

Middlewares

Mautic leverages middlewares before booting Symfony, see app/middlewares. For example, \Mautic\Middleware\Dev\IpRestrictMiddleware restricts IP address access to index_dev.php.

Custom Translator

Mautic has a custom Translator that extends Symfony’s Translator component and enables Mautic’s distributable language package model. All Plugins and bundles should contain US English language strings by default. https://github.com/mautic/language-packer integrates with Transifex to create language packs stored in https://github.com/mautic/language-packs.