You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a single file application! Upload "`api.php`" somewhere and enjoy!
20
25
21
26
For local development you may run PHP's built-in web server:
@@ -134,8 +139,9 @@ Related projects:
134
139
-[PHP-CRUD-UI](https://github.com/mevdschee/php-crud-ui): Single file PHP script that adds a UI to a PHP-CRUD-API project.
135
140
-[PHP-CRUD-ADMIN](https://github.com/mevdschee/php-crud-admin): Single file PHP script that adds a database admin interface to a PHP-CRUD-API project.
136
141
-[PHP-SP-API](https://github.com/mevdschee/php-sp-api): Single file PHP script that adds a REST API to a SQL database.
137
-
-[VUE-CRUD-UI](https://github.com/nlware/vue-crud-ui): Single file Vue.js script that adds a UI to a PHP-CRUD-API project.
138
142
-[ra-data-treeql](https://github.com/nkappler/ra-data-treeql): NPM package that provides a [Data Provider](https://marmelab.com/react-admin/DataProviderIntroduction.html) for [React Admin](https://marmelab.com/react-admin/).
143
+
-[scriptPilot/vueuse](https://github.com/scriptPilot/vueuse/): Vue [Composables](https://vuejs.org/guide/reusability/composables.html) in addition to [VueUse.org](https://vueuse.org/) (that support PHP-CRUD-API).
144
+
-[VUE-CRUD-UI](https://github.com/nlware/vue-crud-ui): Single file Vue.js script that adds a UI to a PHP-CRUD-API project.
139
145
140
146
There are also ports of this script in:
141
147
@@ -285,7 +291,7 @@ On list operations you may apply filters and joins.
285
291
### Filters
286
292
287
293
Filters provide search functionality, on list calls, using the "filter" parameter. You need to specify the column
288
-
name, a comma, the match type, another commma and the value you want to filter on. These are supported match types:
294
+
name, a comma, the match type, another comma and the value you want to filter on. These are supported match types:
289
295
290
296
- "cs": contain string (string contains value)
291
297
- "sw": start with (string starts with value)
@@ -572,7 +578,7 @@ This adjusts the titles of the posts. And the return values are the number of ro
572
578
[1,1]
573
579
574
580
Which means that there were two update operations and each of them had set one row. Batch operations use database
575
-
transactions, so they either all succeed or all fail (successful ones get roled back). If they fail the body will
581
+
transactions, so they either all succeed or all fail (successful ones get rolled back). If they fail the body will
576
582
contain the list of error documents. In the following response the first operation succeeded and the second operation
577
583
of the batch failed due to an integrity violation:
578
584
@@ -667,7 +673,7 @@ You can enable the following middleware using the "middlewares" config parameter
667
673
- "multiTenancy": Restricts tenants access in a multi-tenant scenario
668
674
- "pageLimits": Restricts list operations to prevent database scraping
669
675
- "joinLimits": Restricts join parameters to prevent database scraping
670
-
- "textSearch": Search in all text fields with a simple paramater
676
+
- "textSearch": Search in all text fields with a simple parameter
671
677
- "customization": Provides handlers for request and response customization
672
678
- "json": Support read/write of JSON strings as JSON objects/arrays
673
679
- "xml": Translates all input and output from JSON to XML
@@ -709,6 +715,7 @@ You can tune the middleware behavior using middleware specific configuration par
709
715
- "dbAuth.passwordFormField": The name of the form field that holds the password ("password")
710
716
- "dbAuth.newPasswordFormField": The name of the form field that holds the new password ("newPassword")
711
717
- "dbAuth.registerUser": JSON user data (or "1") in case you want the /register endpoint enabled ("")
718
+
- "dbAuth.loginAfterRegistration": 1 or zero if registered users should be logged in after registration ("")
712
719
- "dbAuth.passwordLength": Minimum length that the password must have ("12")
713
720
- "dbAuth.sessionName": The name of the PHP session that is started ("")
714
721
- "jwtAuth.mode": Set to "optional" if you want to allow anonymous access ("required")
@@ -765,7 +772,7 @@ In the sections below you find more information on the built-in middleware.
765
772
### Authentication
766
773
767
774
Currently there are five types of authentication supported. They all store the authenticated user in the `$_SESSION` super global.
768
-
This variable can be used in the authorization handlers to decide wether or not sombeody should have read or write access to certain tables, columns or records.
775
+
This variable can be used in the authorization handlers to decide wether or not somebody should have read or write access to certain tables, columns or records.
769
776
The following overview shows the kinds of authentication middleware that you can enable.
770
777
771
778
| Name | Middleware | Authenticated via | Users are stored in | Session variable |
@@ -782,7 +789,7 @@ Below you find more information on each of the authentication types.
782
789
783
790
API key authentication works by sending an API key in a request header.
784
791
The header name defaults to "X-API-Key" and can be configured using the 'apiKeyAuth.header' configuration parameter.
785
-
Valid API keys must be configured using the 'apiKeyAuth.keys' configuration parameter (comma seperated list).
792
+
Valid API keys must be configured using the 'apiKeyAuth.keys' configuration parameter (comma separated list).
786
793
787
794
X-API-Key: 02c042aa-c3c2-4d11-9dae-1a6e230ea95e
788
795
@@ -832,7 +839,7 @@ Note that this middleware uses session cookies and stores the logged in state on
832
839
833
840
**Login using views with joined table**
834
841
835
-
For login operations, it is possible to use a view as the usersTable. Such view can return a filtered result from the users table, e.g., *where active = true* or it may also return a result multiple tables thru a table join. At a minimum, the view should include the ***username*** and ***password***.
842
+
For login operations, it is possible to use a view as the usersTable. Such view can return a filtered result from the users table, e.g., *where active = true* or it may also return a result multiple tables thru a table join. At a minimum, the view should include the ***username*** and ***password*** and a field named ***id***.
836
843
837
844
However, views with joined tables are not insertable ([see issue 907](https://github.com/mevdschee/php-crud-api/issues/907) ). As a workaround, use the property ***loginTable*** to set a different reference table for login. The **usersTable** will still be set to the normal, insertable users table.
838
845
@@ -1394,6 +1401,9 @@ The following errors may be reported:
1394
1401
| 1017 | 403 Forbidden | Bad or missing XSRF token
1395
1402
| 1018 | 403 Forbidden | Only AJAX requests allowed
1396
1403
| 1019 | 403 Forbidden | Pagination Forbidden
1404
+
| 1020 | 409 Conflict | User already exists
1405
+
| 1021 | 422 Unprocessable entity | Password too short
1406
+
| 1022 | 422 Unprocessable entity | Username is empty
1397
1407
| 9999 | 500 Internal server error | Unknown error
0 commit comments