スキップしてメイン コンテンツに移動

投稿

ラベル(override)が付いた投稿を表示しています

Override Symfony2 Original Request Class

Have you ever wanted to override Symfony2 core Request class? I am the one of them. Actually what I have would liked to do is overriding isSecure method in Request class bceause of our server configuration was a bit tricky. I have googled a bit and found useful article on Symfony2 ofiicial document . It says &quotyou should use setFactoryMethod&quot. HOWEVER &quotThe setFactory() method was added in Symfony 2.4&quot. I have used Symfony2.3.X because that version has long maintenance term. I have googled and finally found the solution for Symfony 2.3.X. You just modify request creation part in web/app.php (and web/app_dev.php). require_once __DIR__.'/../app/AppKernel.php'; //require_once __DIR__.'/../app/AppCache.php'; $kernel = new AppKernel('prod', false); $kernel->loadClassCache(); //$kernel = new AppCache($kernel); // You should modify here... // ORIGINAL // $request = Request::createFromGlobals(); // I have added my original r...