skillfed

tree-sitter-php

PHP grammar for tree-sitter

tree-sitter-php v0.24.1 7.3M downloads/30d#1,755 on PyPI232
Permissive license MIT Active released

What it is and what it does

tree-sitter-php is a language grammar module that provides PHP syntax parsing for the tree-sitter incremental parsing framework. It enables developers to parse PHP code into abstract syntax trees for analysis, transformation, or tooling purposes. The package provides precompiled binaries for major platforms (macOS x86/arm, Linux x86/arm, Windows), reducing installation friction compared to building from source.

The package is part of the broader tree-sitter ecosystem and is actively maintained, with recent commits and no known security vulnerabilities. It requires Python 3.10 or later and has no runtime dependencies beyond the tree-sitter framework itself.

Use it for:

  • Build linters or code formatters that analyze PHP syntax trees for style violations or refactoring opportunities.
  • Implement static analysis tools that traverse PHP ASTs to detect bugs, security issues, or code smells.
  • Create IDE extensions or editor plugins that provide syntax highlighting or navigation for PHP.
  • Parse and transform PHP code programmatically for code generation, migration, or automated refactoring.
  • Analyze large PHP codebases to extract metrics, dependencies, or architectural patterns.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a PHP language grammar for tree-sitter, enabling incremental parsing and syntax tree analysis of PHP code.

Yes, if you need to parse or analyze PHP code programmatically within the tree-sitter ecosystem. The package is actively maintained, has no security vulnerabilities, uses a permissive MIT license, and medium install friction is acceptable for a compiled grammar. Not necessary if you're not already using tree-sitter or if you only need basic PHP tokenization.

Install

tree-sitter-php on PyPI

pip

pip install tree-sitter-php

uv

uv add tree-sitter-php

poetry

poetry add tree-sitter-php

Installing tree-sitter-php

Before you install

Medium install friction due to compiled wheels; prebuilt binaries available for common platforms (macOS x86/arm, Linux x86/arm, Windows). Requires Python 3.10+. Actively maintained with recent commits and no reported security issues.

License in practice

MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.

Quickstart

pip install tree-sitter-php

Requires Python 3.10 or later; integration with tree-sitter core library required for actual parsing.

Verify before relying

  • How to load and use the grammar binary after installation with tree-sitter bindings.
  • Whether precompiled binaries include the PHP grammar or if separate compilation is needed.
  • API stability and compatibility guarantees across minor versions.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.10)
Install friction medium — platform-specific wheel
Runtime dependencies none
Maintenance actively maintained — 363 days since the last release
Last repo commit
First released
Downloads 7,316,065/month — #1,755 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: tree_sitter_php-0.24.1-cp310-abi3-macosx_10_9_x86_64.whl; tree_sitter_php-0.24.1-cp310-abi3-macosx_11_0_arm64.whl; tree_sitter_php-0.24.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; tree_sitter_php-0.24.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; tree_sitter_php-0.24.1-cp310-abi3-musllinux_1_2_x86_64.whl; tree_sitter_php-0.24.1-cp310-abi3-win_amd64.whl; tree_sitter_php-0.24.1-cp310-abi3-win_arm64.whl

Keywords: incremental, parsing, tree-sitter, php

Intended Audience :: DevelopersTopic :: Software Development :: CompilersTopic :: Text Processing :: LinguisticTyping :: Typed

Tags

php parsing tree-sitterincremental php parserphp syntax treetree-sitter language grammarphp code analysisparse php with tree-sitterphp ast generation
parsingphpast

More Linguistic packages