symfony1 - Symfony 1.2 to 2.3 migration -


i've got pretty big symfony 1.2 project migrate.

first, modified .htaccess can have pages handled symfony 2.

what i'd do, make migration smoother, able render sf2 action/templates/methods/... inside sf1.

i added autoloader sf1 app, can access twig rendering methods , other stuff.

but how can call sf2 action ?

for example, if want migrate footer first, need php methods, not rendering. in sf1 component, should ?

if you've got suggestion way of migrating, don't hesitate !

edit 1 :

apparently, way render full twig template, and/or in template call other partial twig templates render(url, params).

here sf1 code able render twig templates :

public static function gettwig() {      require_once __dir__.'sf2_path/vendor/twig/extensions/lib/twig/extensions/autoloader.php';     twig_autoloader::register();     $loader = new twig_loader_filesystem( __dir__.'sf2_path/sf2/src/vendor/bundle/');     $twig = new twig_environment($loader, array(         'cache' => __dir__.'sf2_path/sf2/app/cache/dev/twig',     ));     return $twig; } 

and :

$twig->loadtemplate('header.html.twig'); 

edit 2 :

that doesn't seem work, if in twig template try render other 1 {{render(controller('bundle:controler:action', {})) }} example twig_error : function "controller" not exist. , if try render url unknown tag name "render".

i guess symfony 2 twig functionalities not loaded, how can ?

edit 3 :

ok, can it, i've got following message...

twig_error_runtime exception has been thrown during rendering of template ("rendering fragment can done when handling master request.") in ...

edit : solved !

here full bootstrap method render twig template , able use symfony 2 functionalities, in symfony 1.

    $loader = require_once __dir__.'/../../../sf2/app/bootstrap.php.cache';     debug::enable();     require_once __dir__.'/../../../sf2/app/appkernel.php';      $kernel = new appkernel('dev', true);     $kernel->loadclasscache();     request::enablehttpmethodparameteroverride();     $request = request::createfromglobals();     $kernel->boot();     $kernel->getcontainer()->enterscope('request');     $kernel->getcontainer()->set('request', new \symfony\component\httpfoundation\request(), 'request');     $this->container = $kernel->getcontainer()->get('twig'); 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -