apishka/easy-extend
最新稳定版本:2.1.1
Composer 安装命令:
composer require apishka/easy-extend
包简介
Easy extends class implementation for PHP
README 文档
README
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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 apishka/easy-extend 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Collection of methods that I or you usually use.
A very simple yet useful helper class to handle PHP file uploads.
Composer plugin for preserving custom paths and supporting nested packages
Composer plugin
Composer plugin that automatically creates directories defined in your composer.json.
Yii2 js base class
统计信息
- 总下载量: 1.93k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 11
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-06-04