Povilas Brilius
2 min readFeb 10, 2021

--

Apparently, there was a problem debugging LAMP and PHP built-in servers on phpleague route package. Comparing the output — /, / on LAMP and built-in servers in addition to /api/v1/ping supposed to emmit JSON validated array, the meld --diff *.txt saving the output var_dump($_SERVER); at the pre-route stage is promising —

Root path for built in and API route for built in $_SERVER dump

You can see clearly, that path information is assigned to only built-in server variables, meaning LAMP is unusable on a traditional HTTP open source foundation (Apache) server. What you can do is add .htaccess server variable assignator in order to solve this simulation package problem.

Open Source Apache2 HTTP server

Actually, I’ll add only RewriteEngine off to .htaccess on the public assets serving folder root — ./bar/ . Because it’s missing key infrastructure requirements like URL usability in terms of target market — consumers, it may fit there.

Then, navigatin to localhost:2150/index.php/api/v1/ping will yield the expected $_SERVER variables dump. You can clearly see

'REQUEST_URI' => string '/index.php/api/v1/ping' (length=22)
...
'PATH_INFO' => string '/api/v1/ping' (length=12)

Let’s see now it in action — index.php

// var_dump($_SERVER);// exit;

It now outputs not default HTTP server 404 Not Found page — exception, but the router fatal error —

Fatal error: Uncaught League\Route\Http\Exception\NotFoundException: Not Found in /var/www/vhosts/fusionote.doctrine/vendor/league/route/src/Dispatcher.php on line 160

To replace it with running page, allowing it catched with BooBoo modern error cather, route has to be modified respectively —

http -hF localhost:2150/index.php/api/v1/pingHTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 29
Content-Type: application/json
Date: Wed, 10 Feb 2021 16:27:54 GMT
Keep-Alive: timeout=5, max=100
Server: Apache/2.4.46 (Ubuntu)
X-Powered-By: PHP/7.4.15
http -F localhost:2150/index.php/api/v1/pingHTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 29
Content-Type: application/json
Date: Wed, 10 Feb 2021 16:31:08 GMT
Keep-Alive: timeout=5, max=100
Server: Apache/2.4.46 (Ubuntu)
X-Powered-By: PHP/7.4.15
{
"data": "pbrilius@gmail.com"
}

So, it’s a usual feedback mechanism, meaning that you can develop just a data series entries on a several strings (TSDB rows) that can help you stay on the indended level as this one, where the API is no questioning PHP compositor routes nor LAMP stack directory indexing of it being provided endogenous variable — means no noise there ;)

--

--

Povilas Brilius

PHP Developer in e-commerce and e-loans industry fields.