承接 able/struct 相关项目开发

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

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

able/struct

Composer 安装命令:

composer require able/struct

包简介

phpABLE struct data type implementation library

README 文档

README

The phpABLE struct emulation library.

Requirements

Features

The mission of this library is to emulate the structures' behavior most naturally.

Install

There's a simple way to install the able/struct package via composer:

composer require able/struct

Usage

Basic

Let's try to declare a structure:

use \Able\Struct;

class MyStruct extends AStruct {

	protected static $Prototype = ['field1', 'field2'];
}

Now we can use it in a siple way:

$Struct = new MyStruct(1,2);
echo $Struct->field1;

//> 1

It's also possible to fill fields later:

$Struct = new MyStruct();

$Struct->field1 = "Test string!";
echo $Struct->field1;

//> Test string!

Mutators

Mutators are pretty helpful in case it needed to customize the default structure behavior.

use \Able\Struct;

class MyStruct extends AStruct {

	protected static $Prototype = ['field1', 'field2'];
	
	protected final function setField1Property($value) {
		return 'The mutated via setter value is: ' . $value;
	}
	
	protected final function getField2Property($value) {
		return 'The mutated via getter value is: ' . $value;
	}
}

Let's test it:

$Struct = new MyStruct(1,2);

echo $Struct->field1;
echo $Struct->field2;

//> The mutated via setter value is: 1
//> The mutated via getter value is: 2

The next example just illustrates the difference between setters and getters.

$Data = $Struct->toArray();

echo $Data['field1'];
echo $Data['field2'];

//> The mutated via setter value is: 1
//> 2

Default values

The default values could be set via constants.

use \Able\Struct;

class MyParentStruct extends AStruct {

	protected static array $Prototype = ['field1', 'field2'];
	
	protected const defaultField1Value = "default value for field1";
	protected const defaultField2Value = "default value for field2";
}

Inheritance

The inheritance level isn't limited. All fields defined at parent classes will also be accessible at child classes.

use \Able\Struct;

class MyParentStruct extends AStruct {

	protected static array $Prototype = ['field1', 'field2'];
}

class MyChildStruct extends MyParentStruct {

	protected static array $Prototype = ['field3'];
}

It perfectly works:

$Struct = new MyChildStruct(1,2,3);

echo $Struct->field1;
echo $Struct->field2;
echo $Struct->field3;

//> 1
//> 2
//> 3

Advanced

To retrieve all structure keys:

$Struct->keys();

To retrieve all structure values:

$Struct->values();

To copy all data into an array:

$Struct->toArray();

To get fields count:

$Struct->count();

To clean all fields and restore its default values:

$Struct->flush();

IDEs support

If you use a PHPDoc-friendly IDE you can gain additional advantages by using the syntax below:

use \Able\Struct;

/**
 * @property int field1
 * @property string field2
 */
class MyStruct extends AStruct {

	protected static array $Prototype = ['field1', 'field2'];
}

License

This package is released under the MIT license.

able/struct 适用场景与选型建议

able/struct 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.09k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 05 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-05-22