7

初めてSilexを使用しています。ローカルで開発している間、すべてが正常に機能します。すべてを本番サーバーにアップロードすると、パラメーター化されたルートは機能しなくなります。

何か考えはありますか?
どこかに本番構成がありませんか?
どこかにファイルパーミッションがありませんか?

次の2つの例外が発生します。

NotFoundHttpException: No route found for "GET /prevendita/hello/sadfasdf"
in /var/www/vhosts/teatrodellamemoria.it/httpdocs/assets/modules/prevendita/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php line 92
  at RouterListener->onKernelRequest(object(GetResponseEvent))
  at call_user_func(array(object(RouterListener), 'onKernelRequest'), object(GetResponseEvent)) in /var/www/vhosts/teatrodellamemoria.it/httpdocs/assets/modules/prevendita/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php line 164
  at EventDispatcher->doDispatch(array(array(object(Application), 'onEarlyKernelRequest'), array(object(SessionServiceProvider), 'onEarlyKernelRequest'), array(object(RouterListener), 'onKernelRequest'), array(object(LocaleListener), 'onKernelRequest'), array(object(Application), 'onKernelRequest')), 'kernel.request', object(GetResponseEvent)) in /var/www/vhosts/teatrodellamemoria.it/httpdocs/assets/modules/prevendita/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php line 53
  at EventDispatcher->dispatch('kernel.request', object(GetResponseEvent)) in /var/www/vhosts/teatrodellamemoria.it/httpdocs/assets/modules/prevendita/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php line 110
  at HttpKernel->handleRaw(object(Request), '1') in /var/www/vhosts/teatrodellamemoria.it/httpdocs/assets/modules/prevendita/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php line 73
  at HttpKernel->handle(object(Request), '1', true) in /var/www/vhosts/teatrodellamemoria.it/httpdocs/assets/modules/prevendita/vendor/silex/silex/src/Silex/Application.php line 509
  at Application->handle(object(Request)) in /var/www/vhosts/teatrodellamemoria.it/httpdocs/assets/modules/prevendita/vendor/silex/silex/src/Silex/Application.php line 484
  at Application->run() in /var/www/vhosts/teatrodellamemoria.it/httpdocs/assets/modules/prevendita/web/index.php line 49

と:

ResourceNotFoundException:
in /var/www/vhosts/teatrodellamemoria.it/httpdocs/assets/modules/prevendita/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcher.php line 81
  at UrlMatcher->match('/prevendita/hello/sadfasdf') in /var/www/vhosts/teatrodellamemoria.it/httpdocs/assets/modules/prevendita/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php line 30
  at RedirectableUrlMatcher->match('/prevendita/hello/sadfasdf') in /var/www/vhosts/teatrodellamemoria.it/httpdocs/assets/modules/prevendita/vendor/silex/silex/src/Silex/LazyUrlMatcher.php line 51
  at LazyUrlMatcher->match('/prevendita/hello/sadfasdf') in /var/www/vhosts/teatrodellamemoria.it/httpdocs/assets/modules/prevendita/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php line 78
  at RouterListener->onKernelRequest(object(GetResponseEvent))
  at call_user_func(array(object(RouterListener), 'onKernelRequest'), object(GetResponseEvent)) in /var/www/vhosts/teatrodellamemoria.it/httpdocs/assets/modules/prevendita/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php line 164
  at EventDispatcher->doDispatch(array(array(object(Application), 'onEarlyKernelRequest'), array(object(SessionServiceProvider), 'onEarlyKernelRequest'), array(object(RouterListener), 'onKernelRequest'), array(object(LocaleListener), 'onKernelRequest'), array(object(Application), 'onKernelRequest')), 'kernel.request', object(GetResponseEvent)) in /var/www/vhosts/teatrodellamemoria.it/httpdocs/assets/modules/prevendita/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php line 53
  at EventDispatcher->dispatch('kernel.request', object(GetResponseEvent)) in /var/www/vhosts/teatrodellamemoria.it/httpdocs/assets/modules/prevendita/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php line 110
  at HttpKernel->handleRaw(object(Request), '1') in /var/www/vhosts/teatrodellamemoria.it/httpdocs/assets/modules/prevendita/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php line 73
  at HttpKernel->handle(object(Request), '1', true) in /var/www/vhosts/teatrodellamemoria.it/httpdocs/assets/modules/prevendita/vendor/silex/silex/src/Silex/Application.php line 509
  at Application->handle(object(Request)) in /var/www/vhosts/teatrodellamemoria.it/httpdocs/assets/modules/prevendita/vendor/silex/silex/src/Silex/Application.php line 484
  at Application->run() in /var/www/vhosts/teatrodellamemoria.it/httpdocs/assets/modules/prevendita/web/index.php line 49

これはコードです:

<?php
require_once __DIR__.'/../vendor/autoload.php';

use Teatro\Models\Reservation;
use Teatro\Models\ReservationsSeat;
use Symfony\Component\Validator\Constraints;
use Symfony\Component\Form\FormError;

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

$app->register(new Silex\Provider\TwigServiceProvider(), array(
    'twig.path' => __DIR__.'/../views',
));
$app->register(
    new Silex\Provider\UrlGeneratorServiceProvider()
);
$app->register(
    new Silex\Provider\SessionServiceProvider(), array(
//        'session.storage.options' => array('name' => 'test')
    )
);
$app->register(
    new Silex\Provider\FormServiceProvider()
);
$app->register(
    new Silex\Provider\ValidatorServiceProvider()
);
$app->register(new Silex\Provider\TranslationServiceProvider(), array(
    'translator.messages' => array(),
));
$app->register(
    new Silex\Provider\SwiftmailerServiceProvider()
);

$app->get('/prevendita/hello/{name}/', function ($name) use ($app) {
    return "Hello $name!";
})->bind('hello_name');

$app->get('/prevendita/hello', function () use ($app) {
    return "Hello!";
})->bind('hello');

$app->run();

開発サーバーはPHP5.4組み込みWebサーバーです本番サーバーはPHP5.3CentOSです

.htaccessファイルは基本的に同じです。本番環境では、silexアプリはドキュメントルートのサブフォルダーにあります。たとえば/ prevenditaなので、追加しました

RewriteRule ^prevendita /prevendita/web/index.php [L]

/prevenditaで始まるリクエストを私のsilexアプリにリダイレクトします

4

2 に答える 2

9

あなたが書いた:

/prevendita/hello/{name}/

しかし、要求された:

/prevendita/hello/sadfasdf

末尾のスラッシュを忘れました。
それが問題だと思います。

編集: Fabien Potencier (Silex の著者) によると:

  • 各リソースには一意の URL が必要です (したがって、/foo/とは異なります/foo)。
  • エンド ユーザー (開発者ではない) の利便性として、URL が で終わる必要があり、入力/を忘れた場合、Silex/は を返す代わりに、( を使用して)正しい URL にユーザーをリダイレクトします404
  • Silex が URL を生成するとき、常に正規の URL を使用するため、ユーザーが手動で URL を入力し、末尾の を追加するのを忘れた場合にのみリダイレクトが行われますが/、フレームワーク自体によって使用されることはありません。
于 2012-07-24T15:59:53.607 に答える
2

最適なオプションは、ドメインを指定し/prevendita/web/、書き換えエンジンを使用してサブディレクトリを処理しないことです。ドメインの下に他のものがあると思うので、Silexアプリを指すことはできないかもしれませんが、サブドメインを使用して、リクエストする代わりにリクエストyourdomain.com/prevendita/web/index.phpすることができますprevendita.yourdomain.com/index.php(ドメインがweb.

于 2014-10-25T02:03:52.063 に答える