symbiotic/full 问题修复 & 功能扩展

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

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

symbiotic/full

Composer 安装命令:

composer require symbiotic/full

包简介

Complete assembly of the SymbioticPHP framework with a cached container and optimized core services

README 文档

README

README.RU.md РУССКОЕ ОПИСАНИЕ

Installation

composer require symbiotic/full

Features

  • PSR friendly
  • Only a few dependencies (only PSR interfaces and PSR-7 implementation).
  • Light weight (440 kb with formatting and comments, assembly in one 200 kb file).
  • Optimized to work in symbiosis with other frameworks.
  • Multilevel DI container system (Core <- Application <- Plugin), with access to the parent container.
  • Virtual file system (proxying static from the package folder to the web).
  • The familiar api of the container (laravel/container).
  • Blade template engine (stripped down), + the ability to add your own template engine.
  • No static collectors (Each package must have already compiled files).
  • Deferred routing (only the routes of the requested application are loaded, determined by the prefix-settlement).
  • The ability to extend the kernel via Bootstrap and Service Provider.
  • Each application has its own container service and services.
  • Cache support (PSR-16 Simple Cache) + Cached DI Container.
  • Middleware support for intercepting a request before loading the core of the framework (response in 1 ms).

For faster work on hosting without PHP optimization, build in one file symbiotic/full-single

Description

The framework was created to simplify the integration of independent small applications into other CMS and frameworks, as well as to expand the functionality of the composer packages.

Ideology is a separate ecosystem of small applications for collaboration with other frameworks and convenient integration of additional functionality.

There are many packages and separately written applications that deliver useful functionality, have their own business logic and sometimes even have their own separate web interface.

In Laravel packages, in Symfony Bundles, in various CMS in the form of plugins and add-ons, all have their own implementation of routing, events, caching, etc. A package written for Laravel to integrate another framework or CMS will be problematic in most cases, and in some cases impossible due to certain dependencies on the framework.

Application developers themselves have to write adaptations for each framework and CMS, which creates a lot of problems and does not cover all ecosystems.

Also, such applications have to do various integrations into the system:

  1. Configure ACL
  2. Integrate the necessary scripts to the admin panel and to the site
  3. Create query handlers and a structure in the database
  4. Configure a bundle with the file system
  5. To save settings and configuration

Such applications include:

  • Single Page Applications
  • Text editors and their plugins with multiple levels of dependency (plugin for plugin)
  • Media Handlers
  • Various optimizers and compressors
  • Applications for administrative work with files and databases
  • Chat bots, messengers, widgets
  • Integration API components, OAuth authorization providers
  • Hosting administration and monitoring tools, analytical tools
  • Landing pages and other micro applications ....

The framework is optimized to work with a large amount of applications, as well as to work as a subsystem for the main framework.

Each application is a composer package, with an additional description directly in the composer.json file.

Run

// If you are already using the framework, then you need to enable the symbiosis mode in the config
// In this mode of operation, the framework will respond only to requests related to it and will not block work for "other" requests.
$config['symbiosis'] = true;

Initialization

The framework is attached from the composer directly to your index.php.

$basePath = dirname(__DIR__);// root folder of the project

include_once $basePath . '/vendor/autoload.php';

include $basePath.'/vendor/symbiotic/full/src/symbiotic.php';

// Then the initialization code and the work of another framework can go on when the symbiosis mode is enabled...
//.... $laravel->handle();

Advanced method with its own configuration

$basePath = dirname(__DIR__);// root folder of the project

include_once $basePath. '/vendor/autoload.php';

$config = include $basePath.'/vendor/symbiotic/full/src/config.sample.php';

//.. Redefining the configuration array

// Basic construction of the Core container
$core = new \Symbiotic\Core\Core($config);

/**
 * When installing the symbiotic/full package, a cached container is available
 * Initialization in this case occurs through the Builder:
 */
$cache = new Symbiotic\Cache\FilesystemCache($config['storage_path'] . '/cache/core');
$core = (new \Symbiotic\Core\ContainerBuilder($cache))
    ->buildCore($config);
    
// Starting request processing
$core->run();

// Then the initialization code and the work of another framework can go on when the symbiosis mode is enabled...
// $laravel->handle();

Package scheme for the framework

The minimum scheme of the application description in the composer.json file:

{
  "name": "vendor/package",
  "require": {
    // ...
  },
  "autoload": {
    // ...
  },
  "extra": {
    "symbiotic": {
      "app": {
        // Application ID
        "id": "my_package_id",
        // Routing provider
        "routing": "\\MyVendor\\MySuperPackage\\Routing",
        // Basic namespace for application controllers
        "controllers_namespace": "\\MyVendor\\MySuperPackage\\Http\\Controllers"
      }
    }
  }
}

Full scheme of package for the framework

{
  "name": "vendor/package",
  "require": {
    // ...
  },
  "autoload": {
    // ...
  },
  // Adding a description of the package for the symbiotic
  "extra": {
    "symbiotic": {
      // Package ID  
      "id": "my_super_package",
      
      // Application description, the package may not have an application section
      "app": {
        // Application ID, specified without the prefix of the parent application
        "id": "image_optimizer",
        // ID of the parent application (optional)
        "parent_app": "media",
        // Application name, used in the application list and menu
        "name": "Media images optimizer",
        // Routing class (optional)
        "routing": "\\MyVendor\\MySuperPackage\\Routing",
        // Basic namespace for controllers (optional)
        "controllers_namespace": "\\Symbiotic\\Develop\\Controllers",
        // Application providers (optional)
        "providers": [
          "MyVendor\\MySuperPackage\\Providers\\AppProvider"
        ],
        // Application container class (optional)
        // Heir from \\Symbiotic\\App\\Application
        "app_class": "MyVendor\\MySuperPackage\\MyAppContainer"
      },
      // Folder with static relative to the package root (will be accessible via the web) (optional)
      "public_path": "assets",
      // Folder with templates and other resources (not accessible via the Web) (optional)
      "resources_path": "my_resources",
      
      // Framework Core Extensions

      // Bootstrappers (optional)
      "bootstrappers": [
        "MyVendor\\MySuperPackage\\CoreBootstrap"
      ],
      // Providers (optional)
      "providers": [
        "MyVendor\\MySuperPackage\\MyDbProvider"
      ],
      // Exclusion of kernel providers (optional)
      "providers_exclude": [
        // Exclusion of providers from downloading
        // For example, with two packages of the same library, it allows you to exclude unnecessary
      ],
      // Event subscribers (optional)
      "events": {
        "handlers": {
          "Symbiotic\\Form\\FormBuilder": "MyVendor\\MyApp\\Events\\FilesystemFieldHandler",
          "Symbiotic\\Settings\\FieldTypesRepository": "MyVendor\\MyApp\\Events\\FieldsHandler",
          "Symbiotic\\UIBackend\\Events\\MainSidebar": "MyVendor\\MyApp\\Events\\Menu"
        }
      },
      //Package settings fields (optional)
      "settings_fields": [
        {
          "title": "Fields group 1",
          "name": "group_1",
          "collapsed": 0,
          "type": "group",
          "fields": [
            {
              "label": "Field 1",
              "name": "filed_name_1",
              "type": "text"
            },
            {
              "label": "Select 1",
              "name": "select_1",
              "type": "select",
              "variants": {
                "value1" :"title1",
                "value12" :"title2"
              }
            },
            {
              "label": "Boolean checkbox",
              "name": "debug",
              "description": "Debug mode",
              "type": "boolean"
            }
          ]
        }
      ],
      // Default settings (optional)
      "settings": {
        "filed_name_1": "demo_value",
        "select_1": "value12",
        "debug": "0"
      },
      // Console commands (optional)
      "commands": {
        "worker": "MyVendor\\MyApp\\Commands\\Worker",
        "stop": "MyVendor\\MyApp\\Commands\\Stop"
      }
    }
  }
}

When configuring the application, you can not specify paths for statics and resources, then default paths will be defined.:

  • public_path = assets
  • resources_path = resources

Templates should always be in the /view/ directory in the resources folder!

Types of packages

All packages for the framework can be divided into several logical categories:

  • Application or plugin
  • Component (any composer package that needs settings or working with resources)
  • Core extension (replaces or adds key core components of the framework)
  • Static package (design theme, package with public files for the web)

Any package can combine all of the above.

Sample file structure of the package

There is no clear mandatory structure, you can use any one. If you are making an application based on the composer package (library), to avoid confusion, it is recommended to put all the code for the application in the src/Symbiotic folder.

vendor/
   -/my_vendor
      -/my_package_name
           -/assets          - Public files
                -/js
                -/css
                -/...
           -/resources       - Resources
                -/views      - View templates
                -/...
           -/src             - php code
               -/Http
                   -/Cоntrollers
                   -/...
               -/Services
                ...
               -/Routing.php
          -/composer.json

symbiotic/full 适用场景与选型建议

symbiotic/full 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 79 次下载、GitHub Stars 达 8, 最近一次更新时间为 2021 年 08 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2021-08-28