motana/multikernel 问题修复 & 功能扩展

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

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

motana/multikernel

Composer 安装命令:

composer require motana/multikernel

包简介

Motana Multi-Kernel Bundle

README 文档

README

Build Status Coverage Status Latest Stable Version Total Downloads Latest Unstable Version License composer.lock

This bundle extends a Symfony3 project by the ability to use multiple apps in the same project directory, all running with the same front controller and bin/console.

Routing within the apps will work as usual, which means already existing routes will continue to work. Each app will be made available with its kernel name as URL prefix by the front controller. The bin/console replacement is able to run commands like cache:clear, cache:pool:clear and assets:install for all apps in one run, which will make the SensioDistributionBundle run those commands for all apps when running composer install or composer update.

Since the BootKernel is a modified Symfony Kernel with almost all features disabled, the penalty of having a prefixed extra kernel is rather small.

Installation

Step 1: Download the bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

$ composer require motana/multikernel

in a shell.

Step 2: Enable the bundle

Enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project. Make sure it is registered after the SensioGeneratorBundle:

    // app/AppKernel.php

    // ...
    class AppKernel extends Kernel
    {    
        // ...
        public function registerBundles()
        {
	        // ...
            $bundles[] = new Motana\Bundle\MultikernelBundle\MotanaMultikernelBundle();
            
            return $bundles;
        }
        // ...
    }

Step 3: Use the commands of the bundle to convert your project

Open a command console, enter your project directory and execute the following command to convert your project:

$ bin/console multikernel:convert

How the filesystem structure is changed

Running the multikernel:convert command will make the following changes to the filesystem structure of the project:

  • A boot kernel skeleton will be created into the apps/ subdirectory of your project
  • All found apps will be copied to apps/<DIR_NAME>
  • The kernel of every app will be modified to run with the BootKernel
  • Configuration of the apps are modified to reflect the filesystem structure changes
  • The front controller and bin/console are replaced

After all modifications have taken place, the original app directories and also all files and directories under var/cache/, var/logs and var/sessions are removed.

The command makes the following changes to each app kernel to make it work in a multikernel environment:

  • Use clauses are replaced to use classes from the MotanaMultikernelBundle
  • The methods getCacheDir(), getLogDir() and registerContainerConfiguration() are removed

The command changes the configuration of each app for a changed directory scheme under var/:

  • Caches for each kernel are stored in var/cache/<KERNEL_NAME>/<ENVIRONMENT_NAME>/
  • Logs for each kernel are stored in var/logs/<KERNEL_NAME>/<ENVIRONMENT_NAME>.log
  • Sessions for each kernel are stored in var/sessions/<KERNEL_NAME>/

After running the multikernel:convert command, run the following commands on a shell:

    $ composer dump-autoload

Configuration

The following settings can be used in apps/config/config.yml to configure the BootKernel:

# Default configuration for "MotanaMultikernelBundle"
motana_multikernel:

    # Default kernel the front controller should load when no kernel matches the URL
    default:              null # Example: "app" for the default AppKernel

    # Class cache configuration
    class_cache:

        # Classes to exclude from being cached in classes.php of app kernels
        exclude:              []

    # Console commands configuration
    commands:

        # Commands to add as multi-kernel command, bypassing the requirement of being available for all kernels
        add:                  []

        # Commands that will always be run on the boot kernel and will be hidden in the other kernels
        global:               []

        # Commands that will be hidden in all kernels
        hidden:               []

        # Commands that will be left as-is, overriding all of the above command settings
        ignore:               []

Testing your project

To reflect the changes in the filesystem structure and routing, your phpunit.xml needs to be updated as follows:

Change the KERNEL_CLASS setting to BootKernel

        <server name="KERNEL_CLASS" value="BootKernel" />

To select a kernel in your tests extending Symfony\Bundle\FrameworkBundle\Test\WebTestCase simply prefix the kernel name to the URL used in the test.

Credits

Portions of this bundle are based on work of Fabien Potencier <fabien@symfony.com> and Jean-François Simon <contact@jfsimon.fr>.

License

This bundle is licensed under the MIT license - see the LICENSE file for details.

motana/multikernel 适用场景与选型建议

motana/multikernel 是一款 基于 HTML 开发的 Composer 扩展包,目前已累计 46 次下载、GitHub Stars 达 1, 最近一次更新时间为 2017 年 06 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 motana/multikernel 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: HTML

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-06-13