PHPackages                             linzhen/code\_generate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. linzhen/code\_generate

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

linzhen/code\_generate
======================

013PHP

Since Oct 12Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Smiler94/code_generate)[ Packagist](https://packagist.org/packages/linzhen/code_generate)[ RSS](/packages/linzhen-code-generate/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependenciesVersions (1)Used By (0)

codeGenerate
------------

[](#codegenerate)

a simple demo to generate php code

### usage

[](#usage)

#### install

[](#install)

clone the resposity

`$ git clone https://github.com/Smiler94/code_generate.git`

install the dependencies

`$ composer install`

#### use

[](#use)

```
require_once __DIR__.'/vendor/autoload.php';

use generator\Property;
use generator\Method;
use generator\Classes;
$property = (new Property('test'))
        ->addComment('a test property')
        ->setStatic(true)
        ->indent(0)
        ->setPrivilege(Property::PRIVILEGE_PROTECTED)
        ->setValue('dddd');
        // ->generate();

echo $property;
//
//
$method = (new Method('test'))
        ->addComment('a test method')
        ->addComment(' ')
        ->addComment('@author linzhen 2017-07-03 16:17:02')
        ->setStatic(true)
        ->indent(1)
        ->addBody('return true');

echo $method;

$class = (new Classes('Test'))
        ->addComment('a test class')
        ->setNameSpace('generate')
        ->addTrait('\generate\Method')
        ->addExtend('extend')
        ->addImplement('implement')
        ->addImplement('implement2');

$prop = $class->addProperty('prop1', '')
        ->addComment('prop1')
        ->setPrivilege('private');

$method = $class->addMethod('method1')
        ->addComment('a test method')
        ->addComment(' ')
        ->addComment('@author linzhen 2017-07-04 09:55:57')
        ->setPrivilege('public')
        ->addParam('arg1')
        ->addBody('return true');

$method2 = $class->addMethod('method2')
        ->addComment('a test method2')
        ->addComment(' ')
        ->addComment('@author linzhen 2017-07-04 09:55:57')
        ->setPrivilege('private')
        ->addParam('arg1')
        ->addBody('');
echo $class;
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/54062ee788f98602c843199972c9bb7e54728acfc0f3ca386d41f8ad0f9e4a76?d=identicon)[Smiler94](/maintainers/Smiler94)

---

Top Contributors

[![Smiler94](https://avatars.githubusercontent.com/u/9924085?v=4)](https://github.com/Smiler94 "Smiler94 (5 commits)")

### Embed Badge

![Health badge](/badges/linzhen-code-generate/health.svg)

```
[![Health](https://phpackages.com/badges/linzhen-code-generate/health.svg)](https://phpackages.com/packages/linzhen-code-generate)
```

###  Alternatives

[kkszymanowski/traitor

Add a trait use statement to existing PHP class

1305.2M16](/packages/kkszymanowski-traitor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
