Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

I am currently working with an old vanilla PHP codebase and I am supposed to make a few improvements.
I am supposed to create some new APIs and but unfortunately at the moment, the logistics of introducing a framework like Laravel or Symfony are not quite simple.
So to make things something work, I have created a folder called api under the root directory and added a .htaccess file under it with the following content
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteBase /api/
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
and under it, I also have an index.php file, where I hope to put my endpoints with following code
<?php
use Dotenv\Dotenv;
use Psr\Http\Message\ServerRequestInterface;
use Laminas\Diactoros\ServerRequestFactory;
use Laminas\HttpHandlerRunner\Emitter\SapiEmitter;
use Laminas\Diactoros\ResponseFactory;
use League\Route\Router;
use League\Route\Strategy\JsonStrategy;
define('BASE_DIR', dirname(__DIR__));
require BASE_DIR . '/vendor/autoload.php';
$dotenv = Dotenv::createImmutable(BASE_DIR);
$dotenv->load();
$response_factory = new ResponseFactory();
$strategy = new JsonStrategy($response_factory);
/** @var Router $router */
$router = (new Router)->setStrategy($strategy);
$router->get('/', function (ServerRequestInterface $request): array {
var_dump($request);
return [
'name' => 'kelly',
];
});
$request = ServerRequestFactory::fromGlobals(
$_SERVER,
$_GET,
$_POST,
$_COOKIE,
$_FILES
);
$response = $router->dispatch($request);
// send the response to the browser
(new SapiEmitter)->emit($response);
I am using the thephpleague/route to handle my routing and a few other packages to handle other needs.
But when I visit http://backend-demo.localhost/api/ I get the following
backend-demo.localhost is configured as a virtual host in my local apache setup.
My guess is the 404 status is being caused by the .htaccess configuration.
What can I do to make this work?
Thank you.
gerard
Jon Harris
orbitstorm88
rem3n
yolanda smith
301276acdc124dd982fe86364ba8c4
30ddab6038c044188d489290785dcb
699c9bc0a2c34f248e792cb8d2c6ab
Kent Morlan
sylvaticus
agitechcr
8b8f3c8ea96345bf8ddb0a59a008e2