Skip to content

Commit 0d7d24e

Browse files
committed
Update maintainer docs with some more general info
1 parent bde52f9 commit 0d7d24e

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

docs/pie-maintainers-handbook.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,48 @@ developing on PIE, you will likely need to run some, or all, of these tests by h
6363
> [!TIP]
6464
> The development guide is primarily aimed at Linux systems, please adjust accordingly for your own platform.
6565
66+
### Architecture overview
67+
68+
Some key concepts are used in PIE;
69+
70+
- **Target PHP**: PIE can be invoked like `/path/to/php /path/to/pie ...` or with
71+
`pie --with-php-config=/path/to/php/config`. This means that the PHP instance running PIE may not be the same PHP
72+
instance we're installing the extensions for. For example, if you're using Ondrej Sury's DEB installer, you could
73+
invoke `/usr/bin/php8.4 /usr/local/bin/pie --with-php-config=/usr/bin/php-config7.2` which would run PIE with
74+
PHP 8.4, but compile and install the extension for the PHP 7.2 instance. In the code, this is represented by the
75+
`\Php\Pie\Platform\TargetPhp\PhpBinaryPath` class.
76+
- **Target Platform**: Along with the above **Target PHP**, the Target Platform describes other facets of the platform,
77+
such as OS, thread safety option, architecture (`x86_64`, `x86`, `arm64`, etc.). This is represented by the
78+
`\Php\Pie\Platform\TargetPlatform` class.
79+
80+
#### Entry point and DI
81+
82+
When running for development, `bin/pie` bootstraps a Symfony Console `Application` using `Container::factory()`, which
83+
wires everything with the [Laravel/Illuminate Container](https://laravel.com/docs/container).
84+
85+
This entrypoint is also used by the PHAR file when built.
86+
87+
#### Typical extension installation flow
88+
89+
The flow for resolving and installing an extension:
90+
91+
1. **Resolve**`DependencyResolver` (`src/DependencyResolver/`) uses Composer's solver via
92+
`ResolveDependencyWithComposer` to find a compatible `ResolvedPackageRequest`.
93+
2. **Download** – Composer's installer downloads/extracts the source. However, `OverrideDownloadUrlInstallListener` is
94+
is a Composer plugin listener that potentially changes the download URL, for example when using Windows, or the
95+
pre-built source or pre-built binary options are used.
96+
3. **Build**`Build` (`src/Building/`) runs `phpize` + `./configure` + `make` (`UnixBuild`) or uses the pre-built DLL
97+
on Windows (`WindowsBuild`), unless the pre-built binary option is used.
98+
4. **Install**`Install` (`src/Installing/`) copies the `.so`/`.dll` and enables the extension in the INI via
99+
`Ini\SetupIniApproach` (picks the best strategy: `phpenmod`, `docker-php-ext-enable`, or direct INI edit).
100+
101+
This pipeline is coordinated by `InstallAndBuildProcess` (`src/ComposerIntegration/InstallAndBuildProcess.php`) called
102+
from Composer event listeners in `src/ComposerIntegration/Listeners/`.
103+
104+
The operation mode is tracked by the `PieOperation` enum (`src/ComposerIntegration/PieOperation.php`): `Resolve`,
105+
`Download`, `Build`, `Install`, `Uninstall`. `PieComposerRequest` carries this value plus target platform and configure
106+
options into the Composer run.
107+
66108
### Unit & Integration Tests
67109

68110
> [!CAUTION]
@@ -150,6 +192,10 @@ To attempt to auto-apply CS fixes:
150192
vendor/bin/phpcbf
151193
```
152194

195+
Classes marked `@internal` are not part of PIE's public API. Almost everything in the codebase should be marked as
196+
`@internal`, except things like exceptions. At this time PIE does not provide any extensibility or API surface to
197+
interact with.
198+
153199
As of PIE branch 1.5.x and newer, we use the library
154200
[thecodingmachine/safe](https://github.com/thecodingmachine/safe) to throw
155201
exceptions instead of returning `false` when PHP functions are called. There is

0 commit comments

Comments
 (0)