Skip to content

Commit c1aa630

Browse files
committed
Merge branch 'master' of github.com:mevdschee/php-crud-api
2 parents bb3cc30 + 02d4bf7 commit c1aa630

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ Alternatively you can integrate this project into the web framework of your choi
5555

5656
In these integrations [Composer](https://getcomposer.org/) is used to load this project as a dependency.
5757

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+
5861
## Configuration
5962

6063
Edit the following lines in the bottom of the file "`api.php`":

api.include.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7065,7 +7065,7 @@ private function getRouteNumbers(ServerRequestInterface $request): array
70657065
$method = strtoupper($request->getMethod());
70667066
$path = array();
70677067
$segment = $method;
7068-
for ($i = 1; $segment; $i++) {
7068+
for ($i = 1; strlen($segment) > 0; $i++) {
70697069
array_push($path, $segment);
70707070
$segment = RequestUtils::getPathSegment($request, $i);
70717071
}

api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7065,7 +7065,7 @@ private function getRouteNumbers(ServerRequestInterface $request): array
70657065
$method = strtoupper($request->getMethod());
70667066
$path = array();
70677067
$segment = $method;
7068-
for ($i = 1; $segment; $i++) {
7068+
for ($i = 1; strlen($segment) > 0; $i++) {
70697069
array_push($path, $segment);
70707070
$segment = RequestUtils::getPathSegment($request, $i);
70717071
}

src/Tqdev/PhpCrudApi/Middleware/Router/SimpleRouter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private function getRouteNumbers(ServerRequestInterface $request): array
104104
$method = strtoupper($request->getMethod());
105105
$path = array();
106106
$segment = $method;
107-
for ($i = 1; $segment; $i++) {
107+
for ($i = 1; strlen($segment) > 0; $i++) {
108108
array_push($path, $segment);
109109
$segment = RequestUtils::getPathSegment($request, $i);
110110
}

tests/functional/001_records/003_read_post.log

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,11 @@ Content-Type: application/json; charset=utf-8
66
Content-Length: 58
77

88
{"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"}

0 commit comments

Comments
 (0)