PHPackages                             voku/simple-php-code-parser - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. voku/simple-php-code-parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

voku/simple-php-code-parser
===========================

Get a simple data structure from your php code.

0.20.1(2y ago)485.6k↓43.8%7[3 issues](https://github.com/voku/Simple-PHP-Code-Parser/issues)[15 PRs](https://github.com/voku/Simple-PHP-Code-Parser/pulls)2Apache-2.0PHPPHP &gt;=7.4

Since May 13Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/voku/Simple-PHP-Code-Parser)[ Packagist](https://packagist.org/packages/voku/simple-php-code-parser)[ Docs](https://github.com/voku/Simple-PHP-Code-Parser)[ Fund](https://www.paypal.me/moelleken)[ GitHub Sponsors](https://github.com/voku)[ RSS](/packages/voku-simple-php-code-parser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (9)Versions (69)Used By (2)

[![Build Status](https://github.com/voku/Simple-PHP-Code-Parser/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/voku/Simple-PHP-Code-Parser/actions)[![Codacy Badge](https://camo.githubusercontent.com/9194e0f87811ef68bfe30c57858050eb1f072b12d6b99eb752b9279bd67da1cd/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3266656166326131373961323461356661633939636266363765373264663266)](https://www.codacy.com/manual/voku/Simple-PHP-Code-Parser?utm_source=github.com&utm_medium=referral&utm_content=voku/Simple-PHP-Code-Parser&utm_campaign=Badge_Grade)[![Latest Stable Version](https://camo.githubusercontent.com/c1881734af74b0832863c9d13fbd7a7210847ef21befca65405427e42473aec5/68747470733a2f2f706f7365722e707567782e6f72672f766f6b752f53696d706c652d5048502d436f64652d5061727365722f762f737461626c65)](https://packagist.org/packages/voku/simple-php-code-parser)[![Total Downloads](https://camo.githubusercontent.com/b7b62455de1cac3248ef72844f5ab67e1048d88eabcaf21d3c7312e6376225c7/68747470733a2f2f706f7365722e707567782e6f72672f766f6b752f73696d706c652d7068702d636f64652d7061727365722f646f776e6c6f616473)](https://packagist.org/packages/voku/simple-php-code-parser)[![License](https://camo.githubusercontent.com/5ef6bc40a801504a2a960d73941260879bfd872e62a25201af4be24a798a5341/68747470733a2f2f706f7365722e707567782e6f72672f766f6b752f73696d706c652d7068702d636f64652d7061727365722f6c6963656e7365)](https://packagist.org/packages/voku/simple-php-code-parser)[![Donate to this project using Paypal](https://camo.githubusercontent.com/0d6e4d8b50b5983a58205941b1a581b1305903393b7a39da574e3f60af3c7f5b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617970616c2d646f6e6174652d79656c6c6f772e737667)](https://www.paypal.me/moelleken)[![Donate to this project using Patreon](https://camo.githubusercontent.com/f9e075baad95563481d35174d43ef50757281abb6bc795d0f473fad452afa030/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617472656f6e2d646f6e6174652d79656c6c6f772e737667)](https://www.patreon.com/voku)

❤ Simple PHP Code Parser
========================

[](#-simple-php-code-parser)

You can simply scan a string, a file or a full directory and you can see a simple data structure from your php code.

- Classes (**PHPClass**)
- Properties (**PHPProperties**)
- Constants (**PHPConst**)
- Methods (**PHPMethod**)
- Interfaces (**PHPInterface**)
- Traits (**PHPTrait**)
- Functions (**PHPFunction**)
- Parameter (**PHPParameter**)

This code is forked from [JetBrains/phpstorm-stubs](https://github.com/JetBrains/phpstorm-stubs/tree/master/tests) but you can't use the classes from "phpstorm-stubs" directly, because they are in a test namespace and the autoloader is "autoload-dev", so here is a extended version.

We will use:

- [nikic/PHP-Parser](https://github.com/nikic/PHP-Parser)
- [Reflection](https://www.php.net/manual/en/book.reflection.php)
- [phpDocumentor](https://github.com/phpDocumentor/)
- [PHPStan/phpdoc-parser](https://github.com/phpstan/phpdoc-parser)

### Install via "composer require"

[](#install-via-composer-require)

```
composer require voku/simple-php-code-parser
```

### Quick Start

[](#quick-start)

Parse a string:

```
$code = '
