Closed abdyek closed 4 years ago
Do you have any configuration for Router instance? I've just tried on built-in server and I couldn't see any problem on the router.
My routing is here
// index.php
require 'vendor/autoload.php';
$router = new Buki\Router();
$router->get('/api/:string', function ($val) {
if($val=='test') {
return 'test';
}
});
$router->run();
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
https://localhost:8000/api/test url returned 404 file. But if i change 'api' keyword than it is work correctly.
I've just tried your endpoint according to your codes, it's worked. Maybe we can debug the router on your project. Btw, which version are you using for PHP and the Router?
We found the problem. "api" is a directory in project root file. But we don't understand why the codes isn't work correctly on built-in web server though it is work correctly on xampp.
My php version is 7.4.9
I inclueded the router with composer that composer require izniburak/router
Maybe the .htaccess file ignored by php for built-in.
Of course. .htaccess file will be ignored when using built-in server. Because .htaccess file is an Apache config file. So, I think you can not access to /api/ endpoint on built-in server if you have /api/ directory in base folder.
Thank you for the information. I will close this issue.
I started Built-in server on terminal with
php -S localhost:8000
and it returned 404. I saw any error with same code on xampp server. Doesn't it support builtin web server?