|
1 | | -# PSFS |
2 | | -[](https://scrutinizer-ci.com/g/psfs/core/build-status/master) |
3 | | -[](https://scrutinizer-ci.com/g/psfs/core/?branch=master) |
4 | | -[](https://scrutinizer-ci.com/g/psfs/core/?branch=master) |
| 1 | +# PSFS Core |
| 2 | + |
5 | 3 | [](https://packagist.org/packages/psfs/core) |
6 | 4 | [](https://github.com/psfs/core/tree/master) |
7 | 5 | [](https://www.php.net/releases/8.3/en.php) |
8 | 6 |
|
9 | | -## PHP Simple Fast & Secure Framework |
10 | | - |
11 | | -PSFS is a lightweight PHP framework focused on MVC/API applications with Twig, Propel, and Symfony components. |
| 7 | +PSFS is a lightweight PHP framework for MVC/API applications (Twig + Propel + Symfony components). |
12 | 8 |
|
13 | 9 | ## Runtime baseline |
14 | 10 |
|
15 | | -- Project execution and validation run with Docker Compose. |
16 | | -- Runtime PHP version is **8.3**. |
17 | | -- Default host port is defined in the root `.env` via `HOST_PORT=8008`. |
18 | | -- Main local services in `docker-compose.yml` are `php`, `redis`, and `db`. |
19 | | - |
20 | | -Direct PHP requirements declared in `composer.json`: |
21 | | - |
22 | | -- `php >=8` |
23 | | -- `ext-json` |
24 | | -- `ext-curl` |
25 | | -- `ext-gmp` |
26 | | - |
27 | | -Core package constraints currently used by the framework: |
28 | | - |
29 | | -```text |
30 | | -psfs/propel: dev-master |
31 | | -symfony/console: ^7.4 |
32 | | -symfony/finder: ^7.4 |
33 | | -symfony/translation: ^7.4 |
34 | | -twig/twig: ^3.24 |
35 | | -monolog/monolog: ^3.10 |
36 | | -matthiasmullie/minify: ^1.3 |
37 | | -firebase/php-jwt: ^7.0 |
38 | | -``` |
39 | | - |
40 | | -## Local development |
| 11 | +- Execution and validation use Docker Compose. |
| 12 | +- Target PHP runtime: **8.3**. |
| 13 | +- Main services: `php`, `redis`, `db`. |
| 14 | +- Host port is configured via `.env` (`HOST_PORT=8008` by default). |
41 | 15 |
|
42 | | -Start the stack: |
| 16 | +## Quick start |
43 | 17 |
|
44 | 18 | ```bash |
45 | 19 | docker compose up -d |
46 | 20 | docker compose ps |
47 | 21 | ``` |
48 | 22 |
|
49 | | -The PHP container is usually named `core-php-1`. If needed, discover it with: |
50 | | - |
51 | | -```bash |
52 | | -docker compose ps |
53 | | -docker ps --format '{{.Names}}' |
54 | | -``` |
55 | | - |
56 | | -Run project commands from the PHP container: |
| 23 | +Run project commands inside the PHP container: |
57 | 24 |
|
58 | 25 | ```bash |
59 | | -docker exec <php_container> php -v |
60 | | -docker exec <php_container> composer install |
61 | | -docker exec <php_container> php vendor/bin/phpunit |
| 26 | +docker exec core-php-1 php -v |
| 27 | +docker exec core-php-1 composer install |
| 28 | +docker exec core-php-1 php vendor/bin/phpunit --no-coverage |
62 | 29 | ``` |
63 | 30 |
|
64 | | -The application server exposed by Docker runs: |
| 31 | +If your PHP container name differs: |
65 | 32 |
|
66 | 33 | ```bash |
67 | | -php -S 0.0.0.0:8080 -t ./html |
| 34 | +docker compose ps |
| 35 | +docker ps --format '{{.Names}}' |
68 | 36 | ``` |
69 | 37 |
|
70 | | -and is published on the host as `${HOST_PORT}:8080`. |
| 38 | +## Swoole runtime |
71 | 39 |
|
72 | | -## Swoole runtime (event worker mode) |
73 | | - |
74 | | -PSFS now includes Swoole runtime commands: |
| 40 | +Check and run Swoole commands through `src/bin/psfs`: |
75 | 41 |
|
76 | 42 | ```bash |
77 | | -docker exec <php_container> php /var/www/src/bin/psfs psfs:swoole:check |
78 | | -docker exec <php_container> php /var/www/src/bin/psfs psfs:swoole:start --host=0.0.0.0 --port=8080 |
79 | | -docker exec <php_container> php /var/www/src/bin/psfs psfs:swoole:status |
80 | | -docker exec <php_container> php /var/www/src/bin/psfs psfs:swoole:reload |
81 | | -docker exec <php_container> php /var/www/src/bin/psfs psfs:swoole:stop |
| 43 | +docker exec core-php-1 php /var/www/src/bin/psfs psfs:swoole:check |
| 44 | +docker exec core-php-1 php /var/www/src/bin/psfs psfs:swoole:start --host=0.0.0.0 --port=8080 |
| 45 | +docker exec core-php-1 php /var/www/src/bin/psfs psfs:swoole:status |
| 46 | +docker exec core-php-1 php /var/www/src/bin/psfs psfs:swoole:reload |
| 47 | +docker exec core-php-1 php /var/www/src/bin/psfs psfs:swoole:stop |
82 | 48 | ``` |
83 | 49 |
|
84 | | -Optional compose profile (keeps baseline `php -S` untouched): |
| 50 | +Optional compose profile: |
85 | 51 |
|
86 | 52 | ```bash |
87 | 53 | docker compose --profile swoole up -d php-swoole |
88 | 54 | docker compose --profile swoole ps |
89 | 55 | ``` |
90 | 56 |
|
91 | | -## Consumer install |
92 | | - |
93 | | -If you want to use PSFS as a Composer dependency in another project: |
94 | | - |
95 | | -```bash |
96 | | -composer init |
97 | | -composer require psfs/core |
98 | | -./vendor/bin/psfs psfs:create:root |
99 | | -``` |
100 | | - |
101 | | -The `psfs:create:root` command generates the document root structure. |
102 | | - |
103 | | -Published package note: |
104 | | - |
105 | | -- Packagist stable release is currently `2.0.1`. |
106 | | -- Repository head is on the `2.2.x-dev` development line. |
107 | | - |
108 | | -## Validation |
109 | | - |
110 | | -Mandatory baseline before review: |
111 | | - |
112 | | -```bash |
113 | | -docker compose up -d |
114 | | -docker compose ps |
115 | | -docker exec <php_container> php -v |
116 | | -docker exec <php_container> php vendor/bin/phpunit |
117 | | -``` |
118 | | - |
119 | | -Optional coverage when Xdebug is available: |
120 | | - |
121 | | -```bash |
122 | | -docker exec -e XDEBUG_MODE=coverage <php_container> php vendor/bin/phpunit --coverage-text |
123 | | -``` |
124 | | - |
125 | | -Do not run `php`, `composer`, or `phpunit` directly on the host for project validation. |
126 | | - |
127 | | -## Benchmark (`php -S` vs Swoole direct) |
128 | | - |
129 | | -Run 5 benchmark iterations per mode and aggregate median/IQR: |
130 | | - |
131 | | -```bash |
132 | | -chmod +x tools/benchmark/run-benchmark.sh |
133 | | -tools/benchmark/run-benchmark.sh |
134 | | -``` |
135 | | - |
136 | | -Artifacts: |
137 | | - |
138 | | -- `cache/benchmark/baseline/run-*.json` |
139 | | -- `cache/benchmark/swoole/run-*.json` |
140 | | -- `cache/benchmark/baseline-summary.json` |
141 | | -- `cache/benchmark/swoole-summary.json` |
142 | | - |
143 | | -## Security/Auth contract (v2) |
| 57 | +## Security baseline (v2) |
144 | 58 |
|
145 | | -- Auth/cookies are versioned as **v2** with **legacy fallback in read-only mode**. |
146 | | -- Expected result for invalid auth is `null/null` and the request flow must be stopped. |
147 | | -- Compatibility policy: active fallbacks are temporary and can be removed only with explicit user approval. |
148 | | -- Target cookie policy: |
| 59 | +- Auth/cookies are versioned as `v2`. |
| 60 | +- Legacy fallback remains read-only until explicit removal approval. |
| 61 | +- Invalid auth must result in `null/null` and stop request flow. |
| 62 | +- Cookie policy target: |
149 | 63 | - `HttpOnly=true` |
150 | | - - `Secure=true` when running on HTTPS |
151 | | - - `SameSite=Lax` or `SameSite=Strict` |
| 64 | + - `Secure=true` on HTTPS |
| 65 | + - `SameSite=Lax|Strict` |
152 | 66 | - `Path=/` |
153 | 67 | - coherent `Domain` |
154 | | - - TTL aligned with auth/session policy |
| 68 | + - TTL aligned with session/auth policy |
155 | 69 |
|
156 | | -## Review and commit policy |
| 70 | +## CI/CD security gates |
157 | 71 |
|
158 | | -- Changes must be reviewed by a human before commit. |
159 | | -- Do not auto-commit after automated changes or agent execution. |
| 72 | +Security pipeline blocks merge/release when: |
160 | 73 |
|
161 | | -## Environment variables |
| 74 | +- a `must_pass` security control test fails, |
| 75 | +- any high/critical finding is unresolved, |
| 76 | +- hardening or quality gate returns non-pass. |
162 | 77 |
|
163 | | -Relevant Docker/runtime variables: |
| 78 | +Local pre-check: |
164 | 79 |
|
165 | | -```text |
166 | | -APP_ENVIRONMENT=(local|dev|...|prod) |
167 | | -HOST_PORT=8008 |
168 | | -DEBUG=-xdebug |
169 | | -PHP_TIMEZONE=Europe/Madrid |
170 | | -PHP_OPCACHE=0 |
171 | | -MYSQL_USER=psfs |
172 | | -MYSQL_PASSWORD=psfs |
173 | | -MYSQL_ROOT_PASSWORD=psfs |
174 | | -MYSQL_DATABASE=psfs |
| 80 | +```bash |
| 81 | +act push --container-architecture linux/amd64 |
175 | 82 | ``` |
176 | 83 |
|
177 | | -`DEBUG=-xdebug` loads the Xdebug image variant. An empty value uses the default PHP image. |
178 | | - |
179 | | -## Versioning |
| 84 | +## Install as dependency |
180 | 85 |
|
181 | | -- Packagist stable release: `2.0.1` |
182 | | -- Active development line: `dev-master -> 2.2.x-dev` |
183 | | -- Release/tag policy is documented in `doc/VERSIONING.md` |
| 86 | +```bash |
| 87 | +composer require psfs/core |
| 88 | +./vendor/bin/psfs psfs:create:root |
| 89 | +``` |
184 | 90 |
|
185 | 91 | ## Documentation |
186 | 92 |
|
187 | | -- [General information and contracts](./doc/CONTRACTS.md) |
| 93 | +- [Contracts](./doc/CONTRACTS.md) |
188 | 94 | - [Versioning policy](./doc/VERSIONING.md) |
189 | | -- [Async queue and connector contracts](./doc/contracts/async-jobs-connectors-contracts.md) |
190 | | -- [Security policy](./SECURITY.md) |
| 95 | +- [Async jobs and connectors contracts](./doc/contracts/async-jobs-connectors-contracts.md) |
191 | 96 |
|
192 | | -## Roadmap |
| 97 | +## Notes |
193 | 98 |
|
194 | | -- Framework documentation |
195 | | - - PhpDoc for all files |
196 | | -- Testing |
197 | | - - 100% tests coverage |
| 99 | +- Do not run `php`, `composer`, or `phpunit` directly on host for project validation. |
| 100 | +- Human review is required before committing automated/agent-driven changes. |
0 commit comments