riverside / php-express

:horse: PHP micro-framework inspired by Express.js
https://riverside.github.io/php-express/
MIT License
26 stars 10 forks source link

example 02-views doesn't work on php -S server #5

Open Meleeman01 opened 2 years ago

Meleeman01 commented 2 years ago

https://github.com/riverside/php-express/blob/master/examples/02-views/index.php

it will only show the root route, and the link to the next page is broken. i've been using php7.3 dev server to test the examples.

SpiffGreen commented 4 months ago

For php -S server you'd have to specify the php file to run, say something like: index.php

<?php
  require 'vendor/autoload.php';

  // Fix
  $_SERVER['REQUEST_SCHEME'] = 'http';

  $app = new \PhpExpress\Application();

  $app->get('/', function($req, $res)  {
    $res->send([
      "status" => "success",
      "message" => "API is working fine"
    ]);
  });

  $app->run();

You'd have to run it like this php -S localhost:5000 index.php