定制 asaliev/symfony-yii2-bridge 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

asaliev/symfony-yii2-bridge

最新稳定版本:0.2.0

Composer 安装命令:

composer require asaliev/symfony-yii2-bridge

包简介

README 文档

README

codecov

This bundle was created as part of a workshop presentation for my team. The goal was to tackle a hypothetical scenario where we needed to migrate a legacy Yii2 application to Symfony incrementally. It is not intended to be a production-ready plugin but serves as an example of how such a migration could be approached.

Supports PHP 7.4+ and Symfony 5.4+.

Overview

  • Registers Yii2 routes with Symfony routing component.
  • Dispatches Yii2 routes to Yii2 Application.
  • Yii2 Application is executed via a message bus, keeping the Yii2 application lifecycle intact.

Installation

  1. Install the package via Composer:
composer require asaliev/symfony-yii2-bridge
  1. Register the bundle in your Symfony application:
// config/bundles.php
return [
    // Other bundles...
    Asaliev\Yii2Bridge\Yii2Bundle::class => ['all' => true],
];
  1. Register the yii2 route type in your Symfony application:
# config/routes.yaml
yii2_routes:
  resource: .
  type: yii2_routes
  1. Configure the bundle in your Symfony application:
# config/packages/yii2.yaml
web_config_path: '%kernel.project_dir%/path/to/web.php'
messenger_bus: 'yii.app.bus'

# Optionally override the default Yii2 container class with an adapter which checks whether a service is registered in the Symfony container first.
# Otherwise you may provide your own implementation of `yii\di\Container`.

#override_yii_container_class: 'Asaliev\Yii2Bridge\Application\PsrPreferredContainerAdapter'
  1. Configure the Yii2 message bus in your Symfony application:
# config/packages/messenger.yaml
framework:
    messenger:
        buses:
            # ...Other configs
            yii.app.bus:
                middleware:
                    - App\Middleware\SomeExtraMiddleware
  1. In the Yii2 configuration file, update the Request class to use Asaliev\Yii2Bridge\Http\HeaderlessResponse instead of the default yii\web\Request. This is necessary because Yii2 will output headers and cookies before we have a chance to halt it's output.
# path/to/yii2/web.php
return [
    // ...
    'components' => [
        // ...
        'response' => [
            // ...
            'class' => HeaderlessResponse::class,
        ],
];

License

This project is licensed under the MIT License. See the LICENSE file for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-08