PHPackages                             quintenmbusiness/php-ast-toolkit - 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. quintenmbusiness/php-ast-toolkit

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

quintenmbusiness/php-ast-toolkit
================================

A powerful PHP toolkit for analyzing, modifying, and generating code using AST (Abstract Syntax Tree).

0.1.3(1y ago)19MITPHPPHP &gt;=8.1

Since Dec 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/quintenmbusiness/PhpAstToolkit)[ Packagist](https://packagist.org/packages/quintenmbusiness/php-ast-toolkit)[ RSS](/packages/quintenmbusiness-php-ast-toolkit/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (6)Used By (0)

PhpAstCodeToolkit
=================

[](#phpastcodetoolkit)

PhpAstCodeToolkit is a PHP library that simplifies working with Abstract Syntax Trees (AST) by providing utilities to analyze, modify, and generate PHP code. Built on top of the powerful [nikic/php-parser](https://github.com/nikic/PHP-Parser), it offers a streamlined API for developers.

Features
--------

[](#features)

- Analyze PHP files and extract class, method, and property information.
- Modify existing code structures using a clean object-oriented approach.
- Generate interfaces and classes programmatically.
- Synchronize changes between the AST and source code.
- Lightweight and easy to integrate into any PHP project.

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require quintenmbusiness/php-ast-code-toolkit
```

Usage
-----

[](#usage)

### Analyzing PHP Files

[](#analyzing-php-files)

Use the `DirectoryScanner` to analyze PHP files in a directory and extract class information.

```
use quintenmbusiness\PhpAstCodeGenerationHelper\Core\DirectoryScanner;
use quintenmbusiness\PhpAstCodeGenerationHelper\Core\ClassFilter;

$scanner = new DirectoryScanner();
$classes = $scanner->scan('/path/to/php/files', true);
$filter = new ClassFilter($classes);

// Search for a specific class
$class = $filter->searchByClassName('MyClass')[0];
```

### Modifying a Class

[](#modifying-a-class)

Change the name of a class and update a method:

```
$class->updateName('NewClassName');
$class->methods[0]->updateName('newMethodName');
$class->save();
```

### Generating an Interface

[](#generating-an-interface)

Create an interface from an existing class:

```
$newInterfacePath = '/path/to/NewInterface.php';
$class->createInterfaceVersion(
    newName: 'NewInterface',
    newPath: $newInterfacePath,
    newExtends: null,
    newImplements: [],
    updateOriginal: true
);
```

### Copying a Class

[](#copying-a-class)

Copy a class to a new file:

```
$newFilePath = '/path/to/NewClass.php';
$newClass = $class->copy($newFilePath);
```

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- [nikic/php-parser](https://github.com/nikic/PHP-Parser) (installed automatically via Composer)

Credits
-------

[](#credits)

This library is powered by [nikic/php-parser](https://github.com/nikic/PHP-Parser).

License
-------

[](#license)

PhpAstCodeToolkit is open-source software licensed under the MIT License.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance40

Moderate activity, may be stable

Popularity6

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.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

511d ago

PHP version history (2 changes)0.1PHP &gt;=8.1

0.1.1PHP &gt;=8

### Community

Maintainers

![](https://www.gravatar.com/avatar/0b028522208a993b8bc3838a1910a4008453d9fe6524654d1dc6460df4196cbe?d=identicon)[quintenmbusiness](/maintainers/quintenmbusiness)

---

Top Contributors

[![quintenmbusiness](https://avatars.githubusercontent.com/u/189560517?v=4)](https://github.com/quintenmbusiness "quintenmbusiness (9 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/quintenmbusiness-php-ast-toolkit/health.svg)

```
[![Health](https://phpackages.com/badges/quintenmbusiness-php-ast-toolkit/health.svg)](https://phpackages.com/packages/quintenmbusiness-php-ast-toolkit)
```

###  Alternatives

[symfony/maker-bundle

Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.

3.4k111.1M565](/packages/symfony-maker-bundle)[illuminate/support

The Illuminate Support package.

583107.1M34.4k](/packages/illuminate-support)[roave/backward-compatibility-check

Tool to compare two revisions of a public API to check for BC breaks

5953.3M56](/packages/roave-backward-compatibility-check)[illuminate/events

The Illuminate Events package.

13454.3M1.7k](/packages/illuminate-events)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[recca0120/laravel-erd

Laravel ERD automatically generates Entity-Relationship Diagrams from your Laravel models and displays them using Vuerd.

36072.0k](/packages/recca0120-laravel-erd)

PHPackages © 2026

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