1
votes

I have a symfony2 project and I would like to create route (prefix) which would point to my old project which sits on its own in one folder (its not a MVC project). I have decided to create folder inside vendor with name of my old project (symfony/vendor/myOldProject).

So rules are:

  • http://symfony/oldproject/ -> points to the folder or specific file like (index.php) "symfony/vendor/myOldProject"
  • pass all traffic after oldproject/ (all GET parameters)
  • everything without prefix oldproject will use standard symfony2 routing

Basicaly instead of (routing.yml):

OldProject_homepage:

pattern:  /oldproject/
defaults: { _controller: AcmeDemoBundle:Default:index }

Use:

OldProject_homepage:

pattern:  /project/
defaults: { /vendor/myOldProject }

How to do it?

2

2 Answers

2
votes

I think it's easier to do with a mod_rewrite rule. Heck, just storing old project in a separate folder under web (i.e. /web/project/) should do the trick if you're careful with access rules for code folders

But if you absolutely insist on symfony2 solution, then you will probably need to write a bridge bundle between your old project and new symfony2 one.

Definitely no way to do it like you described in examples.

2
votes

I think this solution will help people who wants to use symfony2 as main project and keep old existing project files in one separate folder and allow traffic with all get arguments.

I have added .htaccess to the symfony2 in /web/ which contains:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(?:(?!oldproject).)*$ app_dev.php [QSA,L]

And I put my old project in /web/oldproject/

This means I can use symfony2 for every traffic:

http://newsymfony/

And for my old project I can use:

http://newsymfony/oldproject/anyfile.php?annyArgument=anyValue

I hope that will help people who wants to migrate from old projects into new ones based on symfony2

Thanks for help