承接 jced-artem/legacy-adapter 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

jced-artem/legacy-adapter

Composer 安装命令:

composer require jced-artem/legacy-adapter

包简介

Flyweight-adapter for using legacy code in modern frameworks with lazy refactor.

README 文档

README

Flyweight-adapter for using legacy code in modern frameworks with lazy refactor.

Install

composer require jced-artem/legacy-adapter

Example

<?php
// legacy_lib.php

include("settings.inc.php");
require("functions.php");
require_once("database.connection.php");

define('SOME_CONST', 'value');

$var1 = funcName(CONST_2);

function get_Var2A($param1, $param2) {
    return functionFromAnotherInclude($param2, $param1);
}

class myClass
{
    var $data = '';
    function getData() {
        global $var1;
        // do somethig
        return get_Var2A($var1, SOME_CONST);
    }
}

include_once("specialCode.php");

function needThis() {
    $obj = new myClass();
    return unknownFunctionFromInclude() + $obj->getData();
}
$var2 = needThis();
printr('{"param":' . $var2 . '; "var": ' . $var1 . '}');

You can use this legacy file anywhere simply:

class MyLib extends LegacyAbstractAdapter
{
    /**
     * Configure flyweight
     */
    protected function configure()
    {
        $this
            ->setLegacyFile('legacy_lib.php')
            ->setLegacyPath('/path/to/includes')
        ;
    }
}

$myLib = new MyLib();

// global vars
$var1 = $myLib->var1;
$var2 = $myLib->var2;

// set value
$myLib->var1 = 'some new value';

// get global functions
$res1 = $myLib->get_Var2A($param1, $param2);
$res2 = $myLib->needThis();

// get printr result
$content = $myLib->getFlyweight()->getContent();

or

class MyLib extends LegacyAbstractAdapter
{
    /**
     * Configure flyweight
     */
    protected function configure()
    {
        $this
            ->setLegacyFile('legacy_lib.php')
            ->setLegacyPath('/path/to/includes')
        ;
    }
    
    // override
    public function needThis()
    {
        return 'dummy value';
    }
    
    // decorate
    public function get_Var2A($param1, $param2)
    {
        return '<font>' . $this->getFlyweight()->call('get_Var2A', [$param1, $param2]); . '</font>';
    }
    
    // and more
}

Methods available in flyweight

getContent() - get echo/print/etc after include file

get($name) - get variable from file

hasVariable($name) - check if variable exists

set($name, $value) - set variable value

hasFunction($name) - check if function exists

call($name, array $parameters = []) - call function

hasClassDeclared($className) - check if class exists

innerClassGetConstant($className, $constantName) - get constsnt from class

innerClassGetInstance($className) - get instance of class which was declared in file

innerClassCallStatic($className, $methodName, array $parameters = []) - call static function of class declared in file

getFunctionNamesList() - list of all function

getVariableNamesList() - list of all variables

getClassNamesList() - list of all classes

Weakness

  1. Singleton-like. You can't create 2 objects because you can't include file 2 times;
  2. Global functions and classes are still global;
  3. Performance can be 2 times lower then native usage include();

jced-artem/legacy-adapter 适用场景与选型建议

jced-artem/legacy-adapter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15 次下载、GitHub Stars 达 9, 最近一次更新时间为 2016 年 12 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 jced-artem/legacy-adapter 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 9
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-12-01