Преглед изворни кода

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

Maurits van der Schee пре 3 година
родитељ
комит
c1aa630c30

+ 3
- 0
README.md Прегледај датотеку

55
 
55
 
56
 In these integrations [Composer](https://getcomposer.org/) is used to load this project as a dependency.
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
 ## Configuration
61
 ## Configuration
59
 
62
 
60
 Edit the following lines in the bottom of the file "`api.php`":
63
 Edit the following lines in the bottom of the file "`api.php`":

+ 1
- 1
api.include.php Прегледај датотеку

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

+ 1
- 1
api.php Прегледај датотеку

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

+ 1
- 1
src/Tqdev/PhpCrudApi/Middleware/Router/SimpleRouter.php Прегледај датотеку

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

+ 8
- 0
tests/functional/001_records/003_read_post.log Прегледај датотеку

6
 Content-Length: 58
6
 Content-Length: 58
7
 
7
 
8
 {"id":2,"user_id":1,"category_id":2,"content":"It works!"}
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…
Откажи
Сачувај