定制 arshidkv12/traitify 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

arshidkv12/traitify

最新稳定版本:v1.0.0

Composer 安装命令:

pie install arshidkv12/traitify

包简介

Traitify is a native PHP extension that provides commonly used traits

README 文档

README

Traitify is a native PHP extension that provides commonly used traits such as Singleton, implemented in C for optimal performance and better memory efficiency.

🧩 Features

  • ✅ Native Traitify\Singleton trait
  • ✅ Automatic singleton management (getInstance())
  • ✅ Proper support for __construct()
  • 🚀 Built for speed — skips PHP overhead
  • 🧠 Extendable for more traits like Macroable, Loggable, etc.

📦 Installation

1. Clone and build

git clone https://github.com/yourname/traitify.git
cd traitify

phpize
./configure --enable-traitify
make
sudo make install

2. Enable in php.ini

extension=traitify.so

✨ Example Usage

Singleton Trait

<?php
use Traitify\Singleton;

class MyService {
    use Traitify\Singleton;

    public function __construct() {
        echo "Constructing...\n";
    }

    public function hello() {
        return "Hello World";
    }
}

$a = MyService::getInstance();
$b = MyService::getInstance();

var_dump($a === $b);   // true
echo $a->hello();      // Hello World

Macroable Trait

<?php

use Traitify\Macroable;

class Tool {
    use Macroable;
}

Tool::macro('greet', fn($name) => "Hello, $name!");
$t = new Tool();
echo $t->greet("Arshid"); // Hello, Arshid

统计信息

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

GitHub 信息

  • Stars: 6
  • Watchers: 0
  • Forks: 2
  • 开发语言: C

其他信息

  • 授权协议: PHP-3.01
  • 更新时间: 2025-08-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固