Silex找不到路线

时间:2017-01-11 21:05:57

标签: php .htaccess routes silex php-7

我有一个带有PHP 7.0和Apache 2.4的Silex 2.0应用程序(在端口8080上),具有以下结构:

silex/
   | - vendor/
   | - web/
        | - index.php
   | - composer.json
   | - .htaccess

composer.json

{
    "require": {
        "php": ">=7",
        "silex/silex": "~2.0"
    }
}

的.htaccess

FallbackResource /silex/web/index.php

网络/ index.php的

<?php

define('APP_ROOT', dirname(__DIR__));
chdir(APP_ROOT);

use Silex\Application;

require 'vendor/autoload.php';

$app = new Application();
$app['debug'] = true;

echo "---------------- I am here! -----------------";

$app->get('/', function() use ($app) {
    echo 'inside get';
   return $app->json(['Hello World!']);
});

$app->run();

问题是:

Silex Error -

我做错了什么?

1 个答案:

答案 0 :(得分:0)

我使用了PHP内置Web服务器,它运行起来像这样:

php -S localhost:8000 -t web /