smartbooster/core-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

smartbooster/core-bundle

Composer 安装命令:

composer require smartbooster/core-bundle

包简介

Bundle grouping all vendor, generic utils and services that we use on each project

README 文档

README

Bundle grouping all vendor, generic utils and services that we use on each project

CI

What's inside !

  • Config IniOverrideConfig service to easily override php.ini options
  • Monitoring routes for uptime tracking, phpinfo debugging and more
  • DataFixtures abstract helper
  • Query functions to extends Doctrine DQL capacity
  • SentryCallback with special CleverCloud dedicated behavior
  • Utils for Array, Date, Math, Regex and String
  • Validator constraints for EmailChain, Modulo, Password and more

Installation

composer require smartbooster/core-bundle

Enable Monitoring routes

To enable the monitoring routes, add the following codes to your config/routes.yaml file :

_smart_core:
    resource: .
    type: smart_core
    # We recommand to restrict thoses routes on a secure subdomain 
    host: "admin.%domain%"

The path ^/anonymous must have PUBLIC_ACCESS in the project security.yaml config for the probe route to be accessible without user

# security.yaml
access_control:
    - { path: ^/anonymous, roles: PUBLIC_ACCESS }

Extra DQL functions

Add the following code to your config/packages/doctrine.yaml according to your missing functions needs:

doctrine:
    # ...
    orm:
        # ...
        dql:
            string_functions:
                group_concat: Smart\CoreBundle\Query\MySQL\GroupConcat

Sentry configuration

To use our SentryCallback add the following to your config/packages/sentry.yaml :

when@prod:
    sentry:
        dsn: '%env(SENTRY_DSN)%'
        options:
            environment: '%env(ENVIRONMENT)%'
            before_send: 'sentry.callback.before_send'
            integrations:
                - 'Sentry\Integration\IgnoreErrorsIntegration'
        register_error_listener: false

services:
    Sentry\Integration\IgnoreErrorsIntegration:
        arguments:
            $options:
                ignore_exceptions:
                    - 'Symfony\Component\Security\Core\Exception\AccessDeniedException'
    sentry.callback.before_send:
        class: 'Smart\CoreBundle\Sentry\SentryCallback'
        factory: [ '@Smart\CoreBundle\Sentry\SentryCallback', 'getBeforeSend' ]

Also declare the following in your config/packages/monolog.yaml :

when@prod:
    monolog:
        handlers:
            # other handlers
            sentry:
                type: service
                id: Sentry\Monolog\Handler

And define the Sentry\Monolog\Handler service in your services.yaml :

services:
    # other services
    Sentry\Monolog\Handler:
        arguments:
            $hub: '@Sentry\State\HubInterface'
            $level: !php/const Monolog\Logger::ERROR

Nelmio Security recommendations

We recommand to setup a Content Security Policy in addition to the config generated by the nelmio security recipe:

nelmio_security:
    # ...
    
    # Content Security Policy
    csp:
        enabled: true
        hosts: []
        content_types: []
        enforce:
            # see full description below
            level1_fallback: true
            # only send directives supported by the browser, defaults to false
            # this is a port of https://github.com/twitter/secureheaders/blob/83a564a235c8be1a8a3901373dbc769da32f6ed7/lib/secure_headers/headers/policy_management.rb#L97
            browser_adaptive:
                enabled: true
            # this is a full list of known case, you must keep only useful script in project
            script-src:
                - 'self'
                - 'unsafe-inline'
                - 'unsafe-eval'
                - 'https://maps.googleapis.com'
                - 'https://use.fontawesome.com'
                - 'https://www.google-analytics.com'
                - 'https://www.youtube.com'
                - 'https://www.youtube-nocookie.com'
                - 'https://js.stripe.com'
                - 'https://canny.io/'
                - 'https://www.google.com/'
                - 'https://www.gstatic.com/'
                - 'https://code.iconify.design'
                - 'https://cdn.jsdelivr.net'
                - 'http://embed.typeform.com'
                - 'https://embed.typeform.com'
            block-all-mixed-content: true # defaults to false, blocks HTTP content over HTTPS transport

Contributing

Pull requests are welcome.

Thanks to everyone who has contributed already.

This project is supported by SmartBooster

smartbooster/core-bundle 适用场景与选型建议

smartbooster/core-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.08k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 12 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「symfony」 「bundle」 「utils」 「core」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 smartbooster/core-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 smartbooster/core-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 smartbooster/core-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 6.08k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 10
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-21