#125 · Programming Language Tools Developer Tool

PHP Parser

Extract namespaces, imports, classes, interfaces, traits, enums, functions, methods, properties, constants, and dependencies from PHP source in a lightweight structural outline.

Developer Input

Local browser processing
levels
Ad space

How to use this developer tool

  1. Paste PHP source.
  2. Select an outline or symbol view.
  3. Choose which members to include.
  4. Parse the code.
  5. Copy or download the structure.

What this developer tool does

It token-protects strings and comments, identifies declarations and their line positions, and exports a readable outline plus JSON-compatible symbol information.

Protect non-code tokens → scan declarations → calculate line positions and symbol types → build outline and counts.

This is a lightweight structural parser, not a complete PHP compiler AST. Dynamic declarations, anonymous classes, and unusual alternative syntax may be incomplete.

Example

Input: a namespaced class with methods.

Output: namespace, dependencies, class name, methods, parameters, and line locations.

Tips for better output

  • Use complete files for accurate namespace and import extraction.
  • Hide private members when documenting a public API.
  • Use the JSON-style output for downstream tooling.

FAQ

How can I extract classes and functions from PHP code?

Paste the file and run the parser to list declarations with line numbers.

How do I generate a PHP code structure tree?

Use Basic Outline or Detailed Structure to produce a nested-looking declaration list.

How can I list all methods in a PHP class online?

The parser detects named methods and records visibility and line position when available.

How do I export PHP symbols as JSON?

Choose Symbol Table and download or copy the serialized symbol array.

What is the difference between a PHP parser and a PHP AST parser?

This tool extracts common structural declarations, while a full AST parser models the entire grammar and expression tree.

Parsed symbols

ModulePurpose
NamespaceNamespace declaration
Dependencyuse/include/require
TypeClass, interface, trait, enum
MemberFunction, method, property, constant

Browse more developer tools

Calldeveloper category hub