atatusoft / ppphp
++PHP is a superset of PHP that compiles to clean PHP output.
Requires
- php: ^8.4
- composer/semver: ^3.4
- nikic/php-parser: ^5.6
- phpstan/phpdoc-parser: ^2.3
- phpstan/phpstan: ^2.2
- symfony/console: ^8.1
- symfony/process: ^8.1
Requires (Dev)
- pestphp/pest: ^5.1
Suggests
None
Provides
None
Conflicts
None
Replaces
- atatusoft-ltd/ppphp-src: 2026.3.1-rc-2
This package is auto-updated.
Last update: 2026-09-14 04:39:34 UTC
README
++PHP
++PHP (pronounced “plus plus PHP”) is a source language and compiler for PHP projects. It adds compile-time type safety and expressive language features, then emits ordinary PHP for the official PHP runtime.
Why ++PHP
++PHP is designed for gradual adoption. Existing .php files can stay in place while selected files move to .ppphp. The compiler checks both kinds of source together and builds one ordinary-PHP application for deployment.
Use ++PHP when you want stronger contracts without introducing a custom runtime:
- catch type, nullability, member, collection, and checked-error mistakes before deployment;
- express typed local variables, erased generics, and typed collections directly in source;
- keep Composer packages and existing PHP code in the same project; and
- deploy generated PHP using familiar PHP and Composer infrastructure.
Releases
See GitHub Releases for available versions and exact installation instructions. Release Candidates are intended for evaluation; Development releases are a separate, explicitly selected channel.
Language Highlights
- Explicitly typed mutable and readonly local bindings
- Strict project-wide typing
- Union, intersection, and DNF types
- Erased generics
- Typed list and map arrays
- Checked errors
- Value-producing
whenexpressions - Mixed
.phpand.ppphpprojects - Deterministic PHP output and source-mapped diagnostics
- Composer-aware builds
- Incremental, hash-verified compiler caching
Example Source And Generated PHP
++PHP source can declare local types that PHP itself does not accept:
<?php function greeting(string $input): string { string $name = trim($input); readonly string $prefix = 'Hello'; return $prefix . ', ' . $name; }
The compiler erases the extension syntax and preserves its type contract as PHPDoc:
<?php declare(strict_types=1); function greeting(string $input): string { /** @var string $name */ $name = trim($input); /** @var string $prefix */ $prefix = 'Hello'; return $prefix . ', ' . $name; }
Generics, typed arrays, checked throws clauses, and when expressions are also compile-time features. Generated code contains ordinary PHP syntax and requires no ++PHP runtime library.
Requirements
- PHP
^8.4 - Composer 2
Native compiler commands allow 512 MiB by default without changing php.ini.
Set PPPHP_COMPILER_MEMORY_LIMIT_MEGABYTES once in your shell or launcher to
choose another allowance. Small mixed projects remain tested at an explicit
128 MiB limit. See memory configuration.
Generated code targets PHP 8.4.
Installation
The following command requires a published Stable release of atatusoft/ppphp. Check available releases first; for a prerelease, use its exact installation instructions instead. RC-1 uses the original package name recorded in its release notes.
composer require --dev atatusoft/ppphp
This selects Stable only and does not fall back to a prerelease if none is available. To evaluate a Release Candidate or Development release, choose an exact version from its release instructions. From a repository checkout, install locked dependencies and run the compiler directly:
composer install php bin/ppphp --help
The Composer package is atatusoft/ppphp; its command is ppphp.
Quick Start
From a project where ++PHP is installed:
vendor/bin/ppphp init vendor/bin/ppphp composer:configure --dry-run vendor/bin/ppphp composer:configure composer update --lock --no-interaction --no-scripts composer dump-autoload --optimize vendor/bin/ppphp check vendor/bin/ppphp build
ppphp init creates ppphp.json and the configured build/ppphp, .ppphp-cache, and stub directories. composer:configure projects root application autoload mappings to generated output while preserving their source forms for analysis.
Use ppphp check [path] to validate the complete project, a directory, or one project-owned source file. Use ppphp build [path] to compile selected .ppphp files and copy selected .php files into the configured output.
See Getting Started for a complete executable example.
Mixed PHP/++PHP Projects
Ordinary .php source retains normal PHP behavior and participates in symbol and type analysis. It is copied byte-for-byte into selected build output. .ppphp source receives the ++PHP language checks and compiles to .php in the same output tree.
Focused commands use valid unselected declarations as context without reporting unrelated errors from unselected bodies. Complete builds are intended for deployment. See Mixed Projects and PHP Interoperability.
Building And Deployment
A complete ppphp build checks the project before replacing the compiler-owned output tree. New PHP files must pass isolated PHP linting, and a failed build preserves the previous successful output. Manifests and source maps record each generated artifact.
Deploy the configured output tree with the root Composer metadata and installed dependencies. Do not execute .ppphp files directly or place hand-maintained files inside build/ppphp. See Build Output and Composer Runtime Integration.
Editor Support
The repository provides bounded definition and semantic-token protocols for editor integrations. They are internal integration surfaces rather than a standalone language server. See the Editor Protocol.
Current Limitations
- Generated source targets PHP 8.4.
- Native
ppphp checkandppphp buildinclude supplemental PHPStan analysis. - Deep analysis of ordinary PHP implementation bodies is supplied by PHPStan.
- Generator-specific compiler-owned flow analysis remains limited.
- Browser compiler analysis is an internal integration protocol, not a supported browser build product.
- No formatter is included.
- No standalone language server is included in this repository.
- Immutable Records, postfix list syntax, Native Type Members, and attribute factory expressions are planned work and are not part of this release.
Documentation
- Language Overview
- Command-Line Interface
- Migrating From PHP
- Generics, Typed Arrays, and Checked Errors
whenExpressions- Diagnostics and Source Maps
- Versioning and Release Notes
Visit ppphplang.org for the public ++PHP website.
Security
Report vulnerabilities privately using the process in SECURITY.md.
Contributing
Repository contributors should read AGENTS.md and the maintainer release guide before changing compiler or release behavior.
License
Licensed under the Apache License 2.0.