vendredi 26 mai 2017

Add rest api with website

I have just created a slim rest api for my website and I want to create my website around the same domain(server).

<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

require '../vendor/autoload.php';
//require '../src/config/db.php';

$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response) {
    $name = $request->getAttribute('name');
    $response->getBody()->write("Hello, $name");

    return $response;
});

#Customer Routes
//require '../src/routes/customer.php';
$app->run();
?>

<!DOCTYPE html>
<html>
    <head></head>
    <body></body>
</html>

Now my webpage is not showing but when I remove the html text it works perfectly.

I just want both my webservice (using slim api) and my website on the same server. Please help.




Aucun commentaire:

Enregistrer un commentaire