PHPackages                             tourze/php-packer-ast - 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. tourze/php-packer-ast

ActiveLibrary

tourze/php-packer-ast
=====================

AST管理和解析工具

0.0.1(1y ago)03533MITPHPPHP ^8.1CI passing

Since Apr 11Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/tourze/php-packer-ast)[ Packagist](https://packagist.org/packages/tourze/php-packer-ast)[ RSS](/packages/tourze-php-packer-ast/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (3)

PHP Packer AST
==============

[](#php-packer-ast)

[![Latest Stable Version](https://camo.githubusercontent.com/ea331a00e28c13e008c57752f0f974158d7c1dfc4edeb18cac30e9302c8e14cb/68747470733a2f2f706f7365722e707567782e6f72672f746f75727a652f7068702d7061636b65722d6173742f762f737461626c65)](https://packagist.org/packages/tourze/php-packer-ast)[![License](https://camo.githubusercontent.com/8d918f81e6bbf68b3aa69094c3869a8bbd2ed4206d6065f82213672f61d75fd4/68747470733a2f2f706f7365722e707567782e6f72672f746f75727a652f7068702d7061636b65722d6173742f6c6963656e7365)](https://packagist.org/packages/tourze/php-packer-ast)[![Build Status](https://github.com/tourze/php-monorepo/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/tourze/php-monorepo)

Introduction
------------

[](#introduction)

**PHP Packer AST** is a library for parsing, managing, and traversing PHP Abstract Syntax Trees (AST). It provides a simple and extensible API to parse PHP code, manage ASTs, and traverse nodes using the visitor pattern.

Features
--------

[](#features)

- Parse PHP code and files into AST
- Efficient AST manager for multiple files
- Visitor pattern support for flexible AST traversal
- Simple error handling mechanism
- Compatible with PHP 8.1 and above

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

[](#installation)

Require via Composer:

```
composer require tourze/php-packer-ast
```

Quick Start
-----------

[](#quick-start)

### Parse PHP Code

[](#parse-php-code)

```
use PhpPacker\Ast\CodeParser;

$parser = new CodeParser();
$ast = $parser->parseCode('');

// Or parse from file
$ast = $parser->parseFile('/path/to/your/file.php');
```

### Use AST Manager

[](#use-ast-manager)

```
use PhpPacker\Ast\AstManager;
use Psr\Log\NullLogger;

$manager = new AstManager(new NullLogger());

// Add AST
$manager->addAst('/path/to/file.php', $ast);

// Get AST
$ast = $manager->getAst('/path/to/file.php');

// Check existence
if ($manager->hasAst('/path/to/file.php')) {
    // ...
}

// Get statistics
$fileCount = $manager->getFileCount();
$nodeCount = $manager->getTotalNodeCount();
```

### Use Visitor Pattern

[](#use-visitor-pattern)

```
use PhpPacker\Ast\Visitor\RenameDebugInfoVisitor;
use PhpParser\NodeTraverser;

$traverser = new NodeTraverser();
$traverser->addVisitor(new RenameDebugInfoVisitor());
$modifiedAst = $traverser->traverse($ast);
```

Documentation
-------------

[](#documentation)

- API documentation: See source code and [tests](./tests)
- Configuration: No additional configuration required
- Advanced: Implement custom visitors by extending `AbstractVisitor`

Contribution Guide
------------------

[](#contribution-guide)

1. Fork and clone this repository
2. Create a new branch for your feature or bugfix
3. Write code and add tests
4. Run tests with PHPUnit
5. Submit a Pull Request

- Please follow PSR coding standards
- Ensure all tests pass before submitting

License
-------

[](#license)

MIT License. See [LICENSE](../../LICENSE) for details.

Authors
-------

[](#authors)

- tourze Team

Changelog
---------

[](#changelog)

See [CHANGELOG](../../CHANGELOG.md) for release notes and upgrade guide.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance49

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

398d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e354fdb316da535dfa8ba2e9193a473c403b6bc6fb9170778d1dc50e304c6e9d?d=identicon)[tourze](/maintainers/tourze)

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-php-packer-ast/health.svg)

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

###  Alternatives

[zircote/swagger-php

Generate interactive documentation for your RESTful API using PHP attributes (preferred) or PHPDoc annotations

5.3k132.9M468](/packages/zircote-swagger-php)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k26.2M1.8k](/packages/infection-infection)[danog/madelineproto

Async PHP client API for the telegram MTProto protocol.

3.4k855.0k18](/packages/danog-madelineproto)[tempest/framework

The PHP framework that gets out of your way.

2.1k23.1k9](/packages/tempest-framework)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[api-platform/metadata

API Resource-oriented metadata attributes and factories

223.5M96](/packages/api-platform-metadata)

PHPackages © 2026

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