carta
php-parse(1)

php-parse1

Command line interface for php parser

Usage

php-parse [operations] file1.php [file2.php ...]

php-parse [operations] "<?php code"

Overview

Turn PHP source code into an abstract syntax tree.

Operations is a list of the following options (--dump by default):

-d, --dump

Dump nodes using NodeDumper

-p, --pretty-print

Pretty print file using PrettyPrinter\Standard

-j, --json-dump

Print json_encode() result

--var-dump

var_dump() nodes (for exact structure)

-N, --resolve-names

Resolve names using NodeVisitor\NameResolver

-c, --with-column-info

Show column-numbers for errors (if available)

-P, --with-positions

Show positions in node dumps

-r, --with-recovery

Use parsing with error recovery

--version=VERSION

Target specific PHP version (default: newest)

-h, --help

Display this page

Example:

php-parse -d -p -N -d file.php

Dumps nodes, pretty prints them, then resolves names and dumps them again.

History

  • Debian 13 (Trixie): the text shown here
  • Debian 12 (Bookworm)
  • Debian 11 (Bullseye)
  • Debian 10 (Buster)
  • Debian 9 (Stretch)
  • Debian 8 (Jessie)

--help since Debian 10 (Buster); --json-dump since Debian 11 (Bullseye); --version since Debian 13 (Trixie); --with-column-info since Debian 9 (Stretch); --with-positions since Debian 10 (Buster); --with-recovery since Debian 10 (Buster); -P since Debian 10 (Buster); -c since Debian 9 (Stretch); -h since Debian 10 (Buster); -j since Debian 11 (Bullseye); -r since Debian 10 (Buster).

--serialize-xml until Debian 10 (Buster).

From php-parser 5.4.0-3 in Debian 13 (Trixie). Parsed by carta from the page's man source.