proklung / core-framework-extension-bundle
自定义 Symfony 的核心框架包
Requires
- php: >=7.2 | ^8.0
- doctrine/annotations: ^1.10
- doctrine/cache: ^1.10
- doctrine/common: ^3.0
- doctrine/dbal: 2.13.1
- doctrine/doctrine-bundle: ^2.1
- doctrine/inflector: ^1.4
- doctrine/orm: ^2.7
- doctrine/persistence: ^2.0
- league/html-to-markdown: ^5.0
- php-http/httplug: ^2.2
- spiral/attributes: ^2.8
- symfony/amqp-messenger: ^4.4 || ^5.0
- symfony/cache: ^4.4 || ^5.0
- symfony/config: ^4.4 || ^5.0
- symfony/console: ^4.4 || ^5.0
- symfony/dependency-injection: ^4.4 || ^5.0
- symfony/event-dispatcher: ^4.4 || ^5.0
- symfony/expression-language: ^5.2
- symfony/filesystem: ^4.4 || ^5.0
- symfony/framework-bundle: ^4.4 || ^5.0
- symfony/google-mailer: ^4.4 || ^5.0
- symfony/http-client: ^4.4|^5.0
- symfony/http-foundation: ^4.4 || ^5.0
- symfony/http-kernel: ^4.4 || ^5.0
- symfony/lock: ^4.4 || ^5.0
- symfony/mailer: ^4.4 || ^5.0
- symfony/messenger: ^4.4 || ^5.0
- symfony/mime: ^4.4 || ^5.0
- symfony/monolog-bridge: ^4.4 || ^5.0
- symfony/notifier: ^5.0
- symfony/polyfill-php80: ^1.20
- symfony/polyfill-php81: ^1.22
- symfony/property-access: ^4.4 || ^5.0
- symfony/property-info: ^4.4 || ^5.0
- symfony/redis-messenger: ^4.4 || ^5.0
- symfony/routing: ^4.4 || ^5.0
- symfony/security-csrf: ^4.4 || ^5.0
- symfony/serializer: ^4.4 || ^5.0
- symfony/stopwatch: ^4.4|^5.0
- symfony/twig-bridge: ^4.4 || ^5.0
- symfony/validator: ^4.4 || ^5.0
- symfony/yaml: ^4.4 || ^5.0
Requires (Dev)
- dev-master
- 1.8.6
- 1.8.5
- 1.8.4
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.9
- 1.7.8
- 1.7.7
- 1.7.6
- 1.7.5
- 1.7.4
- 1.7.3
- 1.7.2
- 1.7.1
- 1.7.0
- 1.6.9
- 1.6.8
- 1.6.7
- 1.6.6
- 1.6.5
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.9
- 1.5.8
- 1.5.7
- 1.5.6
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.60
- 1.0.57
- 1.0.56
- 1.0.55
- 1.0.39
- 1.0.38
- 1.0.37
- 1.0.36
- 1.0.35
- 1.0.34
- 1.0.33
- 1.0.32
- 1.0.31
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2024-09-14 20:40:50 UTC
README
这是包含在标准 Symfony 框架(在 Symfony\Bundle\FrameworkBundle\FrameworkBundle
包中)中的内容,但在自定义版本中没有被启用(需要分支)并且包含一些非必需的功能。
"Core" 包。没有它,服务容器的功能将会非常有限(极简)。很多功能将无法工作。
实际上,这是功能减半的 FrameworkBundle
,移除了在自定义构建中不需要的功能 - 表单、工作流、翻译器等。
安装
composer.json
"repositories": [ { "type": "git", "url": "https://github.com/proklung/core.framework.extension.bundle" } ]
composer require proklung/core-framework-extension-bundle
配置文件
位于 local/packages/framework.yaml
(或者对于 WordPress,是 /config/packages/framework.yaml
)。
示例
framework: validation: enabled: true enable_annotations: true cache: enabled: true app: cache.adapter.filesystem system: cache.adapter.system directory: '%kernel.project_dir%/bitrix/cache/symfony' default_memcached_provider: 'memcached://' pools: my_cache_pool: public: true adapter: cache.adapter.filesystem default_lifetime: 600 twig: # Пути к шаблонам default_path: '%kernel.project_dir%/local/twig' paths: '%kernel.project_dir%/local/twig': ~ # С namespace '%kernel.project_dir%/../../vendor/symfony/web-profiler-bundle/Resources/views': WebProfiler cache: false cache_dir: '/bitrix/cache/twig' autoescape: 'name' autoescape_service: ~ autoescape_service_method: ~ base_template_class: 'Twig\Template' debug: '%kernel.debug%' strict_variables: '%kernel.debug%' dbal: enabled: true url: '%env(DATABASE_URL)%' charset: UTF8 default_connection: default types: ~ connections: default: url: "%env(DATABASE_URL)%" dbname: '%env(DB_NAME)%' user: '%env(DB_USER)%' password: '%env(DB_PASSWORD)%' host: localhost mapping_types: enum: string serializer: enabled: true enable_annotations: true max_depth_handler: false name_converter: 'serializer.name_converter.camel_case_to_snake_case' secrets: enabled: true vault_directory: '%kernel.project_dir%/config/secrets/%kernel.environment%' local_dotenv_file: '%kernel.project_dir%/.env.%kernel.environment%.local' decryption_env_var: 'base64:default::SYMFONY_DECRYPTION_SECRET' annotations: enabled: true file_cache_dir: '%kernel.cache_dir%/annotations' cache: 'file' annotations_ttl_cache: 7200 session: enabled: true csrf_protection: enabled: true property_access: enabled: true mailer: enabled: true messenger: enabled: true notifier: enabled: true lock: enabled: true resources: ~
控制台命令
标准命令
debug:router
router:match
debug:event-dispatcher
debug:container
debug:autowiring
config:dump-reference
自动加载 Bitrix 模块的命令
结构遍历安装的模块(在 local
和 bitrix
文件夹中),寻找 cli.php
文件。它应该返回一个包含该模块初始化命令的数组。
return [ new ExampleCommand(), // Должен наследоваться от \Symfony\Component\Console\Command\Command container()->get('console.command.about') // Из глобального контейнера ];
这些命令注册到应用程序的通用命令容器中,并通过 php bin/console
访问。
如果包不在 Bitrix 中运行,这不是问题,功能将被忽略。
扩展
任何扩展都可以通过在 framework.yaml
文件中相应部分的 enabled
参数设置 false
来禁用。
DBAL
Validator
Cache
Serializer
Secrets
Lock
Notifier
Messenger
所有内容请参考 文档
注意事项
- 自动装配
MessageHandlerInterface
不会触发。需要手动编写服务。 - 为了使与服务器上的
RabbitMQ
一起工作的结构生效,PHP 需要安装php_amqp
扩展。
邮件发送者
framework.yaml
:
mailer: enabled: true dsn: gmail+smtp://robotivanov2020:xxjqfjyegwmznrtb@default envelope: recipients: ['example@mail.ru'] # Кастомные параметры default_email_from: 'email@gmail.com' default_email_title: 'Super title' # Шаблон - для strftime, где элемент паттерна обрамлен скобками. dsn_file: file:///upload/emails/{Y}/{m}/{d}/@hash.eml
文件邮件发送者传输
use Symfony\Component\Mime\Email; $email = (new Email()) ->from('from@mail.ru') ->to('example@gmail.com') ->subject('Time for Symfony Mailer!') ->text('Sending emails is fun again!') ->html('<p>See Twig integration for better HTML integration!</p>'); /** @var \Symfony\Component\Mailer\Transport\TransportInterface $factory */ $factory = container()->get('custom_mailer_transports.filesystem'); $factory->send($email);
邮件将写入由 framework.yaml
中 dsn_file
参数指定的地址处的文件。
自定义邮件发送者
$factoryMail = container()->get('mailer_bundle.send_email_via_factory'); $message = $factoryMail->createMessage( 'example@gmail.com', 'Testing', 'Testing body', [ 'Лог' => '/my_app-2021-26-07.log' // Файл приаттачится к письму. ] ); $sender = container()->get('custom_mail_sender'); $sender->sendImmediately($message);
在 PHP >=7.2 上读取 PHP 8 属性
服务
spiral.annotations_selective_reader
- Doctrine 注解和 PHP 8 属性的合并读取器。spiral.psr6_selective_reader
- PSR-6 兼容的缓存合并读取器。spiral.attribute_reader
- PHP 8 属性的独立读取器。spiral.attribute_cached_reader
-spiral.attribute_reader
服务的缓存版本。spiral.annotation_reader
- Spiral Framework 的 Doctrine 注释读取器。spiral.annotation_cached_reader
-spiral.annotation_reader
服务的缓存版本。
如果框架的属性(在 framework.yaml
中)的 cache
参数不等于 file
,则所有缓存的服务版本都将从容器中删除。
缓存参数 - file_cache_dir
和 ttl_cache
- 从 framework.yaml
的配置中获取。