Skip to content

Commit d5d29e9

Browse files
committed
removed webpath configuration
1 parent ee320ed commit d5d29e9

File tree

5 files changed

+11
-32
lines changed

5 files changed

+11
-32
lines changed

README.md

-8
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@ This package provides a platform for creating such RESTFul APIs in PHP
2929

3030
This section explains the configuration for this package which can be configured using config.xml
3131

32-
#### webroot
33-
This is the path where application is deployed relative to htdocs
34-
```
35-
if application is deployed at demo ,
36-
the url looks like http://localhost/demo/myservice
37-
and 'demo' is the webroot
38-
```
39-
4032
#### serializers
4133
Differrent type of data needs to be serialized in differrent formats based on the Accept Header in the request
4234

config.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"webroot":"",
32
"serializers":{
43
"string":{
54
"text/plain":"PhpPlatform\\RESTFul\\Serialization\\StringToPlainTextSerialization"

resources/index.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,18 @@
2222
unset($process);
2323
}
2424

25-
2625
$requestUri = $_REQUEST["__route__"];
27-
$_SERVER['REQUEST_URI'] == $requestUri;
26+
$requestUriActual = $_SERVER['REQUEST_URI'];
27+
$positionOfQueryString = strpos($requestUriActual, '?');
28+
if($positionOfQueryString !== false){
29+
$requestUriActual = substr($requestUriActual, 0,$positionOfQueryString);
30+
}
31+
$appPathEnd = strpos($requestUriActual, $requestUri);
32+
if($appPathEnd !== false){
33+
$appPath = substr($requestUriActual, 0, $appPathEnd);
34+
}
35+
$_SERVER['REQUEST_URI'] = $requestUri;
36+
$_SERVER['PLATFORM_APPLICATION_PATH'] = $appPath;
2837
PhpPlatform\RESTFul\Routing\Route::run($requestUri);
2938

3039
?>

src/RESTFul/Routing/Route.php

-19
Original file line numberDiff line numberDiff line change
@@ -74,25 +74,6 @@ private static function findRoute($uri = null){
7474
$uri = $_SERVER['REQUEST_URI'];
7575
}
7676

77-
$appPath = Settings::getSettings(Package::Name,"appPath");
78-
79-
if(strpos($appPath,"/") !== 0){ // prepend / if needed
80-
$appPath = "/".$appPath;
81-
}
82-
83-
if(strpos($uri,"/") !== 0){ // prepend / if needed
84-
$uri = "/".$uri;
85-
}
86-
87-
if(strpos($uri,$appPath) !== 0){
88-
throw new NotFound();
89-
}else{ // real uri is after webroot
90-
$uri = substr($uri,strlen($appPath));
91-
}
92-
93-
$_SERVER['REQUEST_URI'] = $uri;
94-
$_SERVER['PLATFORM_APPLICATION_PATH'] = $appPath;
95-
9677
$urlPaths = array_diff(explode("/",$uri),array(""));
9778

9879
$route = Settings::getSettings(Package::Name,"routes");

tests/RESTFul/TestBase.php

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ static function setUpBeforeClass(){
2222
// clear caches
2323
SettingsCache::getInstance()->reset();
2424

25-
MockSettings::setSettings("php-platform/restful", "webroot", APP_PATH);
26-
2725
}
2826

2927
function setUp(){

0 commit comments

Comments
 (0)