kleinnner commited on
Commit
ef2867d
·
verified ·
1 Parent(s): def3334

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +409 -0
README.md ADDED
@@ -0,0 +1,409 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PHP CRUD API
2
+
3
+ ![license](https://img.shields.io/badge/license-MIT-blue) ![offline-first](https://img.shields.io/badge/offline--first-air--gap-green) ![audit](https://img.shields.io/badge/audit-SHA3--256-orange) ![category](https://img.shields.io/badge/category-supermarkets-lightgrey)
4
+
5
+ > Anticloud-hardened packaging of the upstream project `PHP_CRUD_API` in category **SUPERMARKETS**. Upstream source is vendored in `UPSTREAM_CLONE/` at the pinned commit below; the 12-improvement overlay lives in `anticloud/`. Every fact in this file traces to a file on disk in this project directory.
6
+
7
+ **Category:** SUPERMARKETS · **Upstream:** https://github.com/mevdschee/php-crud-api · **Upstream pin:** `399a398749ab687a68286260023bd73d79da5f26` · **Vendor:** Anticloud FZ LLE
8
+
9
+ ---
10
+
11
+ ## What This Project Does
12
+
13
+ # PHP-CRUD-API
14
+
15
+ Single file PHP script that adds a REST API to a MySQL/MariaDB, PostgreSQL, SQL
16
+ Server or SQLite database.
17
+
18
+ Howto: Upload "`api.php`" to your webserver, configure it to connect to your
19
+ database, have an instant full-featured REST API.
20
+
21
+ NB: This is the [TreeQL](https://treeql.org) reference implementation in PHP.
22
+
23
+ ## Requirements
24
+
25
+ - PHP 7.2 or higher with PDO drivers enabled for one of these database systems:
26
+ - MySQL 5.7 / MariaDB 10.0 or higher for spatial features in MySQL
27
+ - PostgreSQL 9.5 or higher with PostGIS 2.2 or higher for spatial features
28
+ - SQL Server 2017 or higher (2019 also has Linux support)
29
+ - SQLite 3.22 or higher (spatial features NOT supported)
30
+
31
+ ## Installation
32
+
33
+ Download the "`api.php`" file from the latest release:
34
+
35
+ https://github.com/mevdschee/php-crud-api/releases/latest or direct from:\
36
+ https://raw.githubusercontent.com/mevdschee/php-crud-api/main/api.php
37
+
38
+ This is a single file application! Upload "`api.php`" somewhere and enjoy!
39
+
40
+ For local development you may run PHP's built-in web server:
41
+
42
+ php -S localhost:8080
43
+
44
+ Test the script by opening the following URL:
45
+
46
+ http://localhost:8080/api.php/records/posts/1
47
+
48
+ Don't forget to modify the configuration at the bottom of the file.
49
+
50
+ Alternatively you can integrate this project into the web framework of your
51
+ choice, see:
52
+
53
+ - [Automatic REST API for Laravel](https://tqdev.com/2019-automatic-rest-api-laravel)
54
+ - [Automatic REST API for Symfony 4](https://tqdev.com/2019-automatic-rest-api-symfony)
55
+ - [Automatic REST API for SlimPHP 4](https://tqdev.com/2019-automatic-api-slimphp-4)
56
+
57
+ In these integrations [Composer](https://getcomposer.org/) is used to load this
58
+ project as a dependency.
59
+
60
+ For people that don't use composer, the file "`api.include.php`" is provided.
61
+ This file contains everything from "`api.php`" except the configuration from
62
+ "`src/index.php`" and can be used by PHP's "include" function.
63
+
64
+ ## Configuration
65
+
66
+ Edit the following lines in the bottom of the file "`api.php`":
67
+
68
+ $config = new Config([
69
+ 'username' => 'xxx',
70
+ 'password' => 'xxx',
71
+ 'database' => 'xxx',
72
+ ]);
73
+
74
+ These are all the configuration options and their default value between
75
+ brackets:
76
+
77
+ - "driver": `mysql`, `pgsql`, `sqlsrv` or `sqlite` (`mysql`)
78
+ - "address": Hostname (or filename) of the database server (`localhost`)
79
+ - "port": TCP port of the database server (defaults to driver default)
80
+ - "username": Username of the user connecting to the database (no default)
81
+ - "password": Password of the user connecting to the database (no default)
82
+ - "database": Database the connecting is made to (no default)
83
+ - "command": Extra SQL to initialize the database connection (none)
84
+ - "tables": Comma separated list of tables to publish (defaults to 'all')
85
+ - "mapping": Comma separated list of table/column mappings (no mappping)
86
+ - "geometrySrid": SRID assumed when converting from WKT to geometry (`4326`)
87
+ - "middlewares": List of middlewares to load (`cors`)
88
+ - "controllers": List of controllers to load (`records,geojson,openapi,status`)
89
+ - "customControllers": List of user custom controllers to load (no default)
90
+ - "customOpenApiBuilders": List of user custom OpenAPI builders to load (no
91
+ default)
92
+ - "openApiBase": OpenAPI info
93
+ (`{"info":{"title":"PHP-CRUD-API","version":"1.0.0"}}`)
94
+ - "openApiFilterCount": Number of "filter1" to "filterN" parameters described in
95
+ the OpenAPI specification (`3`)
96
+ - "openApiSubFilterCount": Number of lettered filter parameters, such as
97
+ "filter1a", described per numbered filter (`0`)
98
+ - "cacheType": `TempFile`, `Redis`, `Memcache`, `Memcached` or `NoCache`
99
+ (`TempFile`)
100
+ - "cachePath": Path/address of the cache (defaults to system's temp directory)
101
+ - "cacheTime": Number of seconds the cache is valid (`10`)
102
+ - "jsonOptions": Options used for encoding JSON (`JSON_UNESCAPED_UNICODE`)
103
+ - "debug": Show errors in the "X-Exception" headers (`false`)
104
+ - "basePath": URI base path of the API (determined using PATH_INFO by default)
105
+
106
+ All configuration options are also available as environment variables. Write the
107
+ config option with capitals, a "PHP_CRUD_API_" prefix and underscores for word
108
+ breakes, so for instance:
109
+
110
+ - PHP_CRUD_API_DRIVER=mysql
111
+ - PHP_CRUD_API_ADDRESS=localhost
112
+ - PHP_CRUD_API_PORT=3306
113
+ - PHP_CRUD_API_DATABASE=php-crud-api
114
+ - PHP_CRUD_API_USERNAME=php-crud-api
115
+ - PHP_CRUD_API_PASSWORD=php-crud-api
116
+ - PHP_CRUD_API_DEBUG=1
117
+
118
+ The environment variables take precedence over the PHP configuration.
119
+
120
+ ## Limitations
121
+
122
+ These limitation and constrains apply:
123
+
124
+ - Primary keys should either be auto-increment (from 1 to 2^53) or UUID
125
+ - Composite primary and composite foreign keys are not supported
126
+ - Complex writes (transactions) are not supported
127
+ - Complex queries calling functions (like "concat" or "sum") are not supported
128
+ - Database must support and define foreign key constraints
129
+ - SQLite cannot have bigint typed auto incrementing primary keys
130
+ - SQLite does not support altering table columns (structure)
131
+
132
+ ## Features
133
+
134
+ The following features are supported:
135
+
136
+ - Composer install or single PHP file, easy to deploy.
137
+ - Very little code, easy to adapt and maintain
138
+ - Supports POST variables as input (x-www-form-urlencoded)
139
+ - Supports a JSON object as input
140
+ - Supports a JSON array as input (batch insert)
141
+ - Sanitize and validate input using type rules and callbacks
142
+ - Permission system for databases, tables, columns and records
143
+ - Multi-tenant single and multi database layouts are supported
144
+ - Multi-domain CORS support for cross-domain requests
145
+ - Support for reading joined results from multiple tables
146
+ - Search support on multiple criteria
147
+ - Pagination, sorting, top N list and column selection
148
+ - Relation detection with nested results (belongsTo, hasMany and HABTM)
149
+ - Atomic increment support via PATCH (for counters)
150
+ - Binary fields supported with base64 encoding
151
+ - Spatial/GIS fields and filters supported with WKT and GeoJSON
152
+ - Mapping table and column names to support legacy systems
153
+ - Generate API documentation using OpenAPI tools
154
+
155
+ *(excerpt; full text in `UPSTREAM_CLONE/`)*
156
+
157
+ *Quoted from the upstream `README.md` file in `UPSTREAM_CLONE/`.*
158
+ Project-specific facts detected in this directory:
159
+
160
+ - Ecosystem: **PHP / Composer** (manifests: composer.json, composer.lock; scanned in UPSTREAM_CLONE)
161
+ - Top-level source layout: `docker/`, `examples/`, `extras/`, `scripts/`, `src/`, `stubs/`, `tests/`
162
+ - Snapshot size: **139 files**, **37238 lines of code** (measured; see Benchmarks)
163
+ - Primary languages: `.php` (114), `.sh` (9), `(none)` (8), `.md` (3), `.json` (2), `.lock` (1)
164
+ - Upstream commit pinned for this packaging: `399a398749ab687a68286260023bd73d79da5f26`
165
+
166
+ ---
167
+
168
+ ## Installation
169
+
170
+ Download the "`api.php`" file from the latest release:
171
+
172
+ https://github.com/mevdschee/php-crud-api/releases/latest or direct from:\
173
+ https://raw.githubusercontent.com/mevdschee/php-crud-api/main/api.php
174
+
175
+ This is a single file application! Upload "`api.php`" somewhere and enjoy!
176
+
177
+ For local development you may run PHP's built-in web server:
178
+
179
+ php -S localhost:8080
180
+
181
+ Test the script by opening the following URL:
182
+
183
+ http://localhost:8080/api.php/records/posts/1
184
+
185
+ Don't forget to modify the configuration at the bottom of the file.
186
+
187
+ Alternatively you can integrate this project into the web framework of your
188
+ choice, see:
189
+
190
+ - [Automatic REST API for Laravel](https://tqdev.com/2019-automatic-rest-api-laravel)
191
+ - [Automatic REST API for Symfony 4](https://tqdev.com/2019-automatic-rest-api-symfony)
192
+ - [Automatic REST API for SlimPHP 4](https://tqdev.com/2019-automatic-api-slimphp-4)
193
+
194
+ In these integrations [Composer](https://getcomposer.org/) is used to load this
195
+ project as a dependency.
196
+
197
+ For people that don't use composer, the file "`api.include.php`" is provided.
198
+ This file contains everything from "`api.php`" except the configuration from
199
+ "`src/index.php`" and can be used by PHP's "include" function.
200
+
201
+ *Section quoted from the upstream readme.*
202
+ Overlay install (this project):
203
+
204
+ ```sh
205
+ python -m pip install -e anticloud/ # overlay package with the 12 improvements
206
+ python anticloud/cli.py --help # 13 subcommands, JSON stdout
207
+ ```
208
+
209
+ ---
210
+
211
+ ## Usage
212
+
213
+ This file contains everything from "`api.php`" except the configuration from
214
+ "`src/index.php`" and can be used by PHP's "include" function.
215
+
216
+ *Section quoted from the upstream readme.*
217
+ Anticloud overlay CLI (available in every project):
218
+
219
+ ```sh
220
+ python anticloud/cli.py --help # 13 subcommands, JSON stdout
221
+ python anticloud/cli.py checks # run the 16-check suite
222
+ ```
223
+
224
+ ---
225
+
226
+ ## API
227
+
228
+ Single file PHP script that adds a REST API to a MySQL/MariaDB, PostgreSQL, SQL
229
+ Server or SQLite database.
230
+
231
+ Howto: Upload "`api.php`" to your webserver, configure it to connect to your
232
+ database, have an instant full-featured REST API.
233
+
234
+ NB: This is the [TreeQL](https://treeql.org) reference implementation in PHP.
235
+
236
+ *Section quoted from the upstream readme.*
237
+ ---
238
+
239
+ ## Dependencies
240
+
241
+ | Metric | Value |
242
+ |--------|-------|
243
+ | Ecosystem | PHP / Composer |
244
+ | Manifests detected | composer.json, composer.lock |
245
+ | Files in snapshot | 139 |
246
+ | Lines of code | 37238 |
247
+ | Dependency references | 0 |
248
+ | Upstream license | MIT |
249
+ | Overlay license | Anticommons 0.1.0 |
250
+
251
+ Pinned lockfile: `anticloud/requirements.lock` (hash-pinned, PEP 508). SBOM: `sbom.cdx.json` (CycloneDX 1.5, pinned to the upstream SHA).
252
+
253
+ ---
254
+
255
+ ## Configuration
256
+
257
+ database, have an instant full-featured REST API.
258
+
259
+ NB: This is the [TreeQL](https://treeql.org) reference implementation in PHP.
260
+
261
+ *Section quoted from the upstream readme.*
262
+ Overlay configuration (Anticloud):
263
+
264
+ - `anticloud/` - improvement overlay; environment-driven, no cloud dependency
265
+ - `LEDGERS/` - aioss tamper-evident chain files (per-project, verified with `aioss verify --live`)
266
+ - `ISOLATED_LAB_RESULTS/` - reproducibility record (environment, reproduction steps, result register, evidence)
267
+ - `OFFICIAL_BENCHMARKS/` - 26 framework assessments for this project
268
+
269
+ ---
270
+
271
+ ## Contributing
272
+
273
+ *Excerpt from upstream `CONTRIBUTING.md`:*
274
+
275
+ # Contributing to php-crud-api
276
+
277
+ Pull requests are welcome.
278
+
279
+ ## Use phpfmt
280
+
281
+ Please use "phpfmt" to ensure consistent formatting.
282
+
283
+ ## Run the tests
284
+
285
+ Before you do a PR, you should ensure any new functionality has test cases and that all existing tests are succeeding.
286
+
287
+ ## Run the build
288
+
289
+ Since this project is a single file application, you must ensure that classes are loaded in the correct order.
290
+ This is only important for the "extends" and "implements" relations. The 'build.php' script appends the classes in
291
+ alphabetical order (directories first). The path of the class that is extended or implemented (parent) must be above
292
+ the extending or implementing (child) class when listing the contents of the 'src' directory in this order. If you
293
+ get this order wrong you will see the build will fail with a "Class not found" error message. The solution is to
294
+ rename the child class so that it starts with a later letter in the alphabet than the parent class or that you move
295
+ the parent class to a subdirectory (directories are scanned first).
296
+
297
+ Overlay contributions: run the 16-check suite before opening a pull request:
298
+
299
+ ```sh
300
+ python anticloud/bench/runner.py --cwd anticloud
301
+ ```
302
+
303
+ ---
304
+
305
+ ## License
306
+
307
+ **Upstream license: MIT** (evidence: `LICENSE` in the upstream snapshot).
308
+
309
+ License file excerpt:
310
+
311
+ ```text
312
+ MIT License
313
+
314
+ Copyright (c) 2026 Maurits van der Schee
315
+
316
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
317
+ this software and associated documentation files (the "Software"), to deal in
318
+ the Software without restriction, including without limitation the rights to
319
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
320
+ the Software, and to permit persons to whom the Software is furnished to do so,
321
+ subject to the following conditions:
322
+
323
+ The above copyright notice and this permission notice shall be included in all
324
+ copies or substantial portions of the Software.
325
+
326
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
327
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
328
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
329
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
330
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
331
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
332
+ ```
333
+
334
+ ### Anticommons 0.1.0 overlay
335
+
336
+ The Anticloud integration overlay in `anticloud/` - improvements 1 through 12 listed under Benchmarks - is licensed under **Anticommons 0.1.0**. Upstream code remains under its original MIT terms. See `ANTICOMMONS_LICENSE.md` in this directory for the overlay terms and contact.
337
+
338
+ SPDX: `MIT` (upstream) + Anticommons 0.1.0 (overlay, dual).
339
+
340
+ ---
341
+
342
+ ## Upstream
343
+
344
+ - **Project:** `PHP_CRUD_API` (category: SUPERMARKETS)
345
+ - **Upstream URL:** https://github.com/mevdschee/php-crud-api
346
+ - **Pinned commit (SHA):** `399a398749ab687a68286260023bd73d79da5f26`
347
+ - **Branch:** main
348
+ - **Pin provenance:** resolved during the second documentation pass. The parent-project stamp is explicitly rejected for this project.
349
+ - **Snapshot location:** `UPSTREAM_CLONE/` (vendored, not shipped as-is)
350
+ - **Benchmark snapshot:** `BENCH.json`
351
+
352
+ ---
353
+
354
+ ## Benchmarks
355
+
356
+ Measured by the Anticloud assurance suite. Every value below is read from this
357
+ project's `BENCH.json`, produced by a real run — the SHA3-256 of that file is
358
+ `3462441ee14b359438ff828ffb0ffbe38dc5bc81d6913f349b31e823edf7fa78`.
359
+
360
+ | Framework | Controls | Evidence | Coverage | Result |
361
+ |---|---|---|---|---|
362
+ | OWASP Top 10 for LLM Applications | 10 controls mapped | 10 with evidence | 100.0% | PASS |
363
+ | OWASP Top 10 (2021) | 9 controls mapped | 9 with evidence | 100.0% | PASS |
364
+ | SOC 2 Type II readiness | 9 controls mapped | 9 with evidence | 100.0% | PASS |
365
+ | NIST AI Risk Management Framework | 8 controls mapped | 8 with evidence | 100.0% | PASS |
366
+ | NIST SP 800-53 Rev. 5 | 12 controls mapped | 12 with evidence | 100.0% | PASS |
367
+ | NIST Cybersecurity Framework 2.0 | 8 controls mapped | 8 with evidence | 100.0% | PASS |
368
+ | FedRAMP Rev. 5 | 10 controls mapped | 10 with evidence | 100.0% | PASS |
369
+ | PCI DSS v4.0.1 | 11 controls mapped | 11 with evidence | 100.0% | PASS |
370
+ | ISO/IEC 27001:2022 | 9 controls mapped | 9 with evidence | 100.0% | PASS |
371
+ | MITRE ATT&CK v16 | 12 controls mapped | 12 with evidence | 100.0% | PASS |
372
+ | ML Technology Readiness Level | TRL 8 | 8/8 criteria | | PASS |
373
+
374
+ **Overall: 16/16 checks passing.**
375
+
376
+ See `ISOLATED_LAB_RESULTS/03_Result_Register.md` for the 16-check register with pass condition, command and observed value per check.
377
+
378
+ Framework folders in `OFFICIAL_BENCHMARKS/` state the control set and the
379
+ evidence source bound to each control. This project does not claim an audit
380
+ opinion, a SOC report, a FedRAMP authorisation or a PCI attestation — those are
381
+ issued by an independent assessor.
382
+
383
+
384
+
385
+ ## Archives and Permanent Records
386
+
387
+ | Platform | Identifier | Volume |
388
+ |---|---|---|
389
+ | Harvard Dataverse | DOI 10.7910/DVN/YMJKOG | 145 citable datasets |
390
+ | AIOSS verification kit | DOI 10.7910/DVN/OORKNJ | Offline hash verification |
391
+ | DANS (KNAW/NWO, Netherlands) | 10.17026/PT | EU-recognised archive |
392
+ | Zenodo (CERN) | — | 146 records, DOI-registered |
393
+ | OSF | — | 144 preregistered records |
394
+ | Figshare | author 20849885 | Research data and figures |
395
+ | Internet Archive | aioss-format, Anticode | Permanent binary specification |
396
+ | ORCID | 0009-0009-2233-6107 | Permanent researcher ID |
397
+ | Kaggle | pax-millennium-20 | Reproducible T4 benchmark run |
398
+
399
+
400
+
401
+ ## Press and Independent Publication
402
+
403
+ The PAX benchmark release was distributed by Newsfile wire to 336 outlets
404
+ (312 Web, 23 Terminal, 1 Application), including Yahoo Finance, The Globe
405
+ and Mail, Business Insider, National Post, Financial Post, StreetInsider,
406
+ Digital Journal, Barchart, International Business Times, and Fox News.
407
+ Wire distribution makes the announcement dated, public, and indexed, which
408
+ makes the claim checkable.
409
+