I want to use Symfony2 as back end to create a REST API and use AngularJS as front end. The 2 are completely separated ie Symfony 2 will not render anything, it'll just send json data to AngularJS.
I'm not sure on how to configure my web server (nginx).
The Symfony documentation gives the configuration but it's intended for a site that only uses Symfony, and so everything outside of the /web/ folder is not accessible.
I can see several possibilities:
- Create 2 different directories (eg
/path/frontendand/path/backend) and a corresponding website for both. I would then have 2 different addresses to access the front end and the back end (eghttp://myfrontend.comandhttp://mybackend.com). The problem I see is that I probably won't be able to directly use AJAX calls in AngularJS. - Create 2 different directories (eg
/website/frontendand/website/backend) and only one website. I would then probably need to access the front end and back end with something likehttp://example.com/frontendandhttp://example.com/backend. I'm not sure how to configure the web server though (issue withroot /website/backend/web). - Put the AngularJS directory inside the
webfolder of Symfony, but then I'd need to also change the configuration so that nginx doesn't only server app.php, app_dev.php and config.php. - Put the AngularJS directory in the
srcfolder of Symfony, and have Symfony handle the routing. I don't know if it will mess with AngularJS' one routing. Also I will probably have a few other php that should be accessible, so I'd need to route them through Symfony also.
What would you suggest and why? Maybe I'm missing something obivous?