承接 apishka/easy-extend 相关项目开发

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

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

apishka/easy-extend

最新稳定版本:2.1.1

Composer 安装命令:

composer require apishka/easy-extend

包简介

Easy extends class implementation for PHP

README 文档

README

Current build status image

What is easy extend?

This is composer component which helps developers to write common libraries and extend them in project.

Quick start

  • Add easy-extend to composer requirements of your library
"require": {
    "apishka/easy-extend": "^1.0.0"
}
  • Create .apishka.php (structure documentation). Most common file looks like this:
<?php

return array(
    'easy-extend' => array(
        'finder' => function($finder)
        {
            $finder
                ->in('source/')
                ->files()
                ->name('*.php')
            ;

            return $finder;
        }
    ),
);
  • Run composer update
  • Implement traits to classes which you want to be easy extendable.

How to extend?

Extending classes

Some library has basic implementation of class you want extend and this library implements EasyExtend:

class Library_User_Implementation
{
    /**
     * We have to include trait
     */
    use Apishka\EasyExtend\Helper\ByClassNameTrait;
}

One thing you have to do to extend this class and don't rewrite any library code, or check where new user class should pass is to extends that class:

class My_Library_User_Implementation extends Library_User_Implementation
{
}

One thing you have to do is create new instance of class using

Library_User_Implementation::apishka(); // instanceof My_Library_User_Implementation

All libraries can be easy extended for you custom project with your custom requirements. No need to require tons of code.

##Items routing Create router and realize two methods:

class My_Library_ItemsRouter extends \Apishka\EasyExtend\Router\ByKeyAbstract
{
    protected function isCorrectItem(\ReflectionClass $reflector)
    {
        return $reflector->isSubclassOf('My_Library_ItemsInterface');
    }

    protected function getClassVariants(\ReflectionClass $reflector, $item)
    {
        return $item->getAliases();
    }
}

Create item:

class My_Library_ItemApple implements My_Library_ItemsInterface
{
    public function getAliases()
    {
        return array(
            'apple',
            'red_apple',
        );
    }
}

Now you can get class by alias:

var_dump(
    get_class(My_Library_ItemsRouter::apishka()->getItem('apple')
); // My_Library_ItemApple

var_dump(
    get_class(My_Library_ItemsRouter::apishka()->getItem('red_apple')
); // My_Library_ItemApple

Also you can extend your item:

class My_Library_ItemRedApple extends My_Library_ItemApple
{
}

// after ./vendor/bin/easy-extend
var_dump(
    get_class(My_Library_ItemsRouter::apishka()->getItem('apple')
); // My_Library_ItemRedApple

apishka/easy-extend 适用场景与选型建议

apishka/easy-extend 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.93k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 06 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 apishka/easy-extend 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-04