Browse Source

Merge branch 'master' of github.com:mevdschee/php-crud-api

Maurits van der Schee 3 years ago
parent
commit
c1aa630c30

+ 3
- 0
README.md View File

@@ -55,6 +55,9 @@ Alternatively you can integrate this project into the web framework of your choi
55 55
 
56 56
 In these integrations [Composer](https://getcomposer.org/) is used to load this project as a dependency.
57 57
 
58
+For people that don't use composer, the file "`api.include.php`" is provided. This file contains everything 
59
+from "`api.php`" except the configuration from "`src/index.php`" and can be used by PHP's "include".
60
+
58 61
 ## Configuration
59 62
 
60 63
 Edit the following lines in the bottom of the file "`api.php`":

+ 1
- 1
api.include.php View File

@@ -7065,7 +7065,7 @@ namespace Tqdev\PhpCrudApi\Middleware\Router {
7065 7065
             $method = strtoupper($request->getMethod());
7066 7066
             $path = array();
7067 7067
             $segment = $method;
7068
-            for ($i = 1; $segment; $i++) {
7068
+            for ($i = 1; strlen($segment) > 0; $i++) {
7069 7069
                 array_push($path, $segment);
7070 7070
                 $segment = RequestUtils::getPathSegment($request, $i);
7071 7071
             }

+ 1
- 1
api.php View File

@@ -7065,7 +7065,7 @@ namespace Tqdev\PhpCrudApi\Middleware\Router {
7065 7065
             $method = strtoupper($request->getMethod());
7066 7066
             $path = array();
7067 7067
             $segment = $method;
7068
-            for ($i = 1; $segment; $i++) {
7068
+            for ($i = 1; strlen($segment) > 0; $i++) {
7069 7069
                 array_push($path, $segment);
7070 7070
                 $segment = RequestUtils::getPathSegment($request, $i);
7071 7071
             }

+ 1
- 1
src/Tqdev/PhpCrudApi/Middleware/Router/SimpleRouter.php View File

@@ -104,7 +104,7 @@ class SimpleRouter implements Router
104 104
         $method = strtoupper($request->getMethod());
105 105
         $path = array();
106 106
         $segment = $method;
107
-        for ($i = 1; $segment; $i++) {
107
+        for ($i = 1; strlen($segment) > 0; $i++) {
108 108
             array_push($path, $segment);
109 109
             $segment = RequestUtils::getPathSegment($request, $i);
110 110
         }

+ 8
- 0
tests/functional/001_records/003_read_post.log View File

@@ -6,3 +6,11 @@ Content-Type: application/json; charset=utf-8
6 6
 Content-Length: 58
7 7
 
8 8
 {"id":2,"user_id":1,"category_id":2,"content":"It works!"}
9
+===
10
+GET /records/posts/0
11
+===
12
+404
13
+Content-Type: application/json; charset=utf-8
14
+Content-Length: 46
15
+
16
+{"code":1003,"message":"Record '0' not found"}

Loading…
Cancel
Save