Command reference
The mago ast
command is a powerful inspection tool that tokenizes and parses a single PHP file, giving you insight into its lexical and syntactical structure.
TIP
For global options that can be used with any command, see the Command-Line Interface overview. Remember to specify global options before the ast
command.
Usage: mago ast [OPTIONS] <FILE>
Arguments
<FILE>
Required. The path to the single PHP file you want to inspect.
Options
--tokens
Display the stream of raw tokens generated by the lexer instead of the parsed AST. This is useful for debugging low-level syntax issues. This can be combined with --json
for machine-readable output.
--json
Display the output (either the AST or the token stream) in a machine-readable, pretty-printed JSON format. This is ideal for integration with other tools and scripts.
--names
After parsing the AST, this flag runs the name resolver and prints a list of all symbols (classes, functions, etc.) and their fully qualified names. This is useful for debugging namespace and import resolution.
Shared Reporting Options
The ast
command uses a shared set of options for reporting parsing errors.
See the Shared Reporting and Fixing Options documentation.
TIP
The ast
command only reports parsing errors. Auto-fixing and baseline features are not applicable to this command.
Help
Flag, Alias(es) | Description |
---|---|
--help , -h | Print the help summary for the command. |