Skip to content

Commit 1d2afd5

Browse files
chore: release 1.18.3
1 parent 5cb8808 commit 1d2afd5

14 files changed

Lines changed: 173 additions & 10 deletions

File tree

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "1.18.2"
2+
".": "1.18.3"
33
}

AGENTS.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Agent Guide: Ymir PHP Runtime
2+
3+
This repository contains the Ymir PHP runtime for AWS Lambda. It provides the necessary infrastructure to run PHP applications (WordPress, Laravel, etc.) on Lambda, including support for FastCGI/PHP-FPM.
4+
5+
## Development Commands
6+
7+
### Build & Setup
8+
- **Install Dependencies:** `composer install`
9+
10+
### Quality Control (Linting & Static Analysis)
11+
- **Check Code Style:** `composer php-cs-fixer` (dry-run)
12+
- **Fix Code Style:** `composer php-cs-fixer:fix` (automatically applies fixes)
13+
- **Static Analysis:** `composer phpstan` (PHPStan level 9)
14+
- **Generate Baseline:** `composer phpstan:generate-baseline` (never run this without approval)
15+
- **Rector (Refactoring):** `composer rector` (dry-run)
16+
- **Apply Rector Fixes:** `composer rector:fix`
17+
18+
### Testing
19+
- **Run All Unit Tests:** `composer tests:unit`
20+
- **Run a Single Test File:** `composer tests:unit -- tests/Unit/Path/To/Test.php`
21+
- **Run a Specific Test Method:** `composer tests:unit -- --filter testMethodName`
22+
23+
---
24+
25+
## Code Style & Standards
26+
27+
These are extra rules not covered by PHP-CS-Fixer and Rector.
28+
29+
- Always import classes. Never use the full class name.
30+
31+
---
32+
33+
## Architecture Overview
34+
35+
### Runtime Loop
36+
The runtime operates in a loop, fetching the next invocation from the Lambda Runtime API, handling it, and sending the response back. The core logic resides in `src/AbstractRuntime.php`.
37+
38+
### Event Handlers
39+
Events are processed by handlers implementing `LambdaEventHandlerInterface`.
40+
- **Location:** `src/Lambda/Handler/`
41+
- **Http Handlers:** Special handlers for WordPress, Laravel, Bedrock, and generic PHP scripts. They often inherit from `AbstractHttpRequestEventHandler`.
42+
- **Sqs Handlers:** Handlers for SQS events, inheriting from `AbstractSqsHandler`.
43+
- **Handler Collection:** `LambdaEventHandlerCollection` manages multiple handlers and finds the first one that can handle a given event.
44+
45+
### FastCGI & PHP-FPM
46+
For website runtimes, the runtime starts a PHP-FPM process and communicates with it via FastCGI.
47+
- **FastCGI Client:** Uses `hollodotme/fast-cgi-client`.
48+
- **PhpFpmProcess:** Manages the lifecycle of the PHP-FPM process (start, stop, health checks). See `src/FastCgi/PhpFpmProcess.php`.
49+
50+
### Runtime Context
51+
The `RuntimeContext` class centralizes access to environment variables, logger, and other shared services like `LambdaClient` and `SsmClient`.
52+
53+
### Runtime Build
54+
Docker based runtime build
55+
- **Location:** `runtime/`
56+
57+
---
58+
59+
## Testing Strategy
60+
61+
### Unit Tests
62+
- **Location:** `tests/Unit`
63+
- **Mocking:** Use traits found in `tests/Mock` to facilitate mocking common dependencies.
64+
- `LoggerMockTrait` for `Logger`
65+
- `LambdaRuntimeApiClientMockTrait` for `RuntimeApiClient`
66+
- `LambdaClientMockTrait` for `LambdaClient`
67+
- **PHPUnit Version:** PHPUnit 8 is used. Ensure tests are compatible with this version.
68+
69+
### Test Patterns
70+
- Always test for both successful outcomes and expected exceptions.
71+
- Use `getFunctionMock` from `FunctionMockTrait` to mock global PHP functions like `getenv`, `curl_init`, etc.
72+
- Mock objects should be created using the provided traits whenever possible to maintain consistency.
73+
74+
---
75+
76+
## Implementation Rules for Agents
77+
78+
1. **Verify PSR-4:** Ensure new classes are in the correct namespace under `Ymir\Runtime` (`src/`) or `Ymir\Runtime\Tests` (`tests/`).
79+
2. **Strict Typing:** Always include `declare(strict_types=1);` and use property, parameter, and return types.
80+
3. **Run Linting:** Always run `composer php-cs-fixer:fix` and `composer rector:fix` after modifying code.
81+
4. **Run PHPStan:** Always run `composer phpstan` after changes to ensure type safety. Never fix a PHPStan issue with a comment block.
82+
5. **Mocking:** When writing tests, check `tests/Mock` first to see if a mock trait already exists for the service you are testing.
83+
6. **Environment Variables:** Handle Lambda environment variables via `RuntimeContext` or `getenv()` where appropriate.
84+
7. **No Dependencies:** Avoid adding new dependencies unless absolutely necessary and approved.
85+
8. **Yoda Style:** Maintain Yoda style in all comparisons.
86+
9. **Look around:** Scan nearby files (in the same namespace or unit test files) when creating a new file to figure out the conventions
87+
10. **One level of indentation:** Stick to one level of indentation unless it's impossible to do so. Nested statements should be avoided.

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## [1.18.3](https://github.com/ymirapp/php-runtime/compare/v1.18.2...v1.18.3) (2026-03-09)
4+
5+
6+
### Bug Fixes
7+
8+
* Add php-fpm `log_limit` to prevent long stderr messages from being truncated ([c28ee5f](https://github.com/ymirapp/php-runtime/commit/c28ee5ff6231f9d9136ef9ff60e1d66fa3086c64))
9+
* Restart php-fpm and retry once after fastcgi connect failure ([5cb8808](https://github.com/ymirapp/php-runtime/commit/5cb880870451cb63ba0c34c03a6168470070f28d))
10+
* Write php-fpm errors to stderr ([e24bd86](https://github.com/ymirapp/php-runtime/commit/e24bd862bedcfc4b3d24e90fba52ae65f5b59cf1))
11+
312
## [1.18.2](https://github.com/ymirapp/php-runtime/compare/v1.18.1...v1.18.2) (2026-03-07)
413

514

runtime/depot.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"id": "wmlwprq4n2"
3+
}

runtime/php-72/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ RUN curl -Ls https://pecl.php.net/get/imagick | tar xz && cd imagick-*/ && ${INS
8080

8181
# Composer & Runtime
8282
RUN curl -sS https://getcomposer.org/installer | ${INSTALL_DIR}/bin/php -- --install-dir=${INSTALL_DIR}/bin/ --filename=composer
83-
RUN git clone https://github.com/ymirapp/php-runtime.git /tmp/runtime-build && cd /tmp/runtime-build && git checkout tags/v1.18.2 && cd /opt \
83+
RUN git clone https://github.com/ymirapp/php-runtime.git /tmp/runtime-build && cd /tmp/runtime-build && git checkout tags/v1.18.3 && cd /opt \
8484
&& cp -R /tmp/runtime-build/composer.json /tmp/runtime-build/composer.lock /tmp/runtime-build/runtime/bootstrap /tmp/runtime-build/runtime/runtime.php /tmp/runtime-build/src /tmp/runtime-build/templates ./ \
8585
&& chmod 0555 /opt/bootstrap /opt/runtime.php && /opt/ymir/bin/php /opt/ymir/bin/composer install --no-dev --optimize-autoloader --no-ansi --no-interaction && find /opt/vendor -type d -name "tests" -exec rm -rf {} + && find /opt/vendor -type d -name "test" -exec rm -rf {} + && find /opt/vendor -type d -name "docs" -exec rm -rf {} + && find /opt/vendor -type f -name "*.md" -delete && find /opt/vendor -type f -name "phpunit.xml*" -delete
8686

runtime/php-73/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ RUN curl -Ls https://pecl.php.net/get/imagick | tar xz && cd imagick-*/ && ${INS
8080

8181
# Composer & Runtime
8282
RUN curl -sS https://getcomposer.org/installer | ${INSTALL_DIR}/bin/php -- --install-dir=${INSTALL_DIR}/bin/ --filename=composer
83-
RUN git clone https://github.com/ymirapp/php-runtime.git /tmp/runtime-build && cd /tmp/runtime-build && git checkout tags/v1.18.2 && cd /opt \
83+
RUN git clone https://github.com/ymirapp/php-runtime.git /tmp/runtime-build && cd /tmp/runtime-build && git checkout tags/v1.18.3 && cd /opt \
8484
&& cp -R /tmp/runtime-build/composer.json /tmp/runtime-build/composer.lock /tmp/runtime-build/runtime/bootstrap /tmp/runtime-build/runtime/runtime.php /tmp/runtime-build/src /tmp/runtime-build/templates ./ \
8585
&& chmod 0555 /opt/bootstrap /opt/runtime.php && /opt/ymir/bin/php /opt/ymir/bin/composer install --no-dev --optimize-autoloader --no-ansi --no-interaction && find /opt/vendor -type d -name "tests" -exec rm -rf {} + && find /opt/vendor -type d -name "test" -exec rm -rf {} + && find /opt/vendor -type d -name "docs" -exec rm -rf {} + && find /opt/vendor -type f -name "*.md" -delete && find /opt/vendor -type f -name "phpunit.xml*" -delete
8686

runtime/php-74/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ RUN cp relay.ini ${INSTALL_DIR}/etc/php/conf.d/50-relay.ini; PHP_EXT_DIR=$(${INS
8181

8282
# Composer & Runtime
8383
RUN curl -sS https://getcomposer.org/installer | ${INSTALL_DIR}/bin/php -- --install-dir=${INSTALL_DIR}/bin/ --filename=composer
84-
RUN git clone https://github.com/ymirapp/php-runtime.git /tmp/runtime-build && cd /tmp/runtime-build && git checkout tags/v1.18.2 && cd /opt \
84+
RUN git clone https://github.com/ymirapp/php-runtime.git /tmp/runtime-build && cd /tmp/runtime-build && git checkout tags/v1.18.3 && cd /opt \
8585
&& cp -R /tmp/runtime-build/composer.json /tmp/runtime-build/composer.lock /tmp/runtime-build/runtime/bootstrap /tmp/runtime-build/runtime/runtime.php /tmp/runtime-build/src /tmp/runtime-build/templates ./ \
8686
&& chmod 0555 /opt/bootstrap /opt/runtime.php && /opt/ymir/bin/php /opt/ymir/bin/composer install --no-dev --optimize-autoloader --no-ansi --no-interaction && find /opt/vendor -type d -name "tests" -exec rm -rf {} + && find /opt/vendor -type d -name "test" -exec rm -rf {} + && find /opt/vendor -type d -name "docs" -exec rm -rf {} + && find /opt/vendor -type f -name "*.md" -delete && find /opt/vendor -type f -name "phpunit.xml*" -delete
8787

runtime/php-80/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ RUN cp relay.ini ${INSTALL_DIR}/etc/php/conf.d/50-relay.ini; PHP_EXT_DIR=$(${INS
8181

8282
# Composer & Runtime
8383
RUN curl -sS https://getcomposer.org/installer | ${INSTALL_DIR}/bin/php -- --install-dir=${INSTALL_DIR}/bin/ --filename=composer
84-
RUN git clone https://github.com/ymirapp/php-runtime.git /tmp/runtime-build && cd /tmp/runtime-build && git checkout tags/v1.18.2 && cd /opt \
84+
RUN git clone https://github.com/ymirapp/php-runtime.git /tmp/runtime-build && cd /tmp/runtime-build && git checkout tags/v1.18.3 && cd /opt \
8585
&& cp -R /tmp/runtime-build/composer.json /tmp/runtime-build/composer.lock /tmp/runtime-build/runtime/bootstrap /tmp/runtime-build/runtime/runtime.php /tmp/runtime-build/src /tmp/runtime-build/templates ./ \
8686
&& chmod 0555 /opt/bootstrap /opt/runtime.php && /opt/ymir/bin/php /opt/ymir/bin/composer install --no-dev --optimize-autoloader --no-ansi --no-interaction && find /opt/vendor -type d -name "tests" -exec rm -rf {} + && find /opt/vendor -type d -name "test" -exec rm -rf {} + && find /opt/vendor -type d -name "docs" -exec rm -rf {} + && find /opt/vendor -type f -name "*.md" -delete && find /opt/vendor -type f -name "phpunit.xml*" -delete
8787

runtime/php-81/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ RUN cp relay.ini ${INSTALL_DIR}/etc/php/conf.d/50-relay.ini; PHP_EXT_DIR=$(${INS
7979

8080
# Composer & Runtime
8181
RUN curl -sS https://getcomposer.org/installer | ${INSTALL_DIR}/bin/php -- --install-dir=${INSTALL_DIR}/bin/ --filename=composer
82-
RUN git clone https://github.com/ymirapp/php-runtime.git /tmp/runtime-build && cd /tmp/runtime-build && git checkout tags/v1.18.2 && cd /opt \
82+
RUN git clone https://github.com/ymirapp/php-runtime.git /tmp/runtime-build && cd /tmp/runtime-build && git checkout tags/v1.18.3 && cd /opt \
8383
&& cp -R /tmp/runtime-build/composer.json /tmp/runtime-build/composer.lock /tmp/runtime-build/runtime/bootstrap /tmp/runtime-build/runtime/runtime.php /tmp/runtime-build/src /tmp/runtime-build/templates ./ \
8484
&& chmod 0555 /opt/bootstrap /opt/runtime.php && /opt/ymir/bin/php /opt/ymir/bin/composer install --no-dev --optimize-autoloader --no-ansi --no-interaction && find /opt/vendor -type d -name "tests" -exec rm -rf {} + && find /opt/vendor -type d -name "test" -exec rm -rf {} + && find /opt/vendor -type d -name "docs" -exec rm -rf {} + && find /opt/vendor -type f -name "*.md" -delete && find /opt/vendor -type f -name "phpunit.xml*" -delete
8585

runtime/php-82/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ RUN cp relay.ini ${INSTALL_DIR}/etc/php/conf.d/50-relay.ini; PHP_EXT_DIR=$(${INS
7979

8080
# Composer & Runtime
8181
RUN curl -sS https://getcomposer.org/installer | ${INSTALL_DIR}/bin/php -- --install-dir=${INSTALL_DIR}/bin/ --filename=composer
82-
RUN git clone https://github.com/ymirapp/php-runtime.git /tmp/runtime-build && cd /tmp/runtime-build && git checkout tags/v1.18.2 && cd /opt \
82+
RUN git clone https://github.com/ymirapp/php-runtime.git /tmp/runtime-build && cd /tmp/runtime-build && git checkout tags/v1.18.3 && cd /opt \
8383
&& cp -R /tmp/runtime-build/composer.json /tmp/runtime-build/composer.lock /tmp/runtime-build/runtime/bootstrap /tmp/runtime-build/runtime/runtime.php /tmp/runtime-build/src /tmp/runtime-build/templates ./ \
8484
&& chmod 0555 /opt/bootstrap /opt/runtime.php && /opt/ymir/bin/php /opt/ymir/bin/composer install --no-dev --optimize-autoloader --no-ansi --no-interaction && find /opt/vendor -type d -name "tests" -exec rm -rf {} + && find /opt/vendor -type d -name "test" -exec rm -rf {} + && find /opt/vendor -type d -name "docs" -exec rm -rf {} + && find /opt/vendor -type f -name "*.md" -delete && find /opt/vendor -type f -name "phpunit.xml*" -delete
8585

0 commit comments

Comments
 (0)