Q:

Use a subdomain to access a portion of a web application (Symfony)

I'm building an application in Symfony which can be identified by two distinct portions.

The first is a portion that handles front facing information to users
The second is the heart of the application that is driven by a number of CRUDs, management interfaces and controls to manage the front end

Currently, the two components sit with the following domains structure

Front end interface: www.example.com
Backend admin interface: www.example.com/app

Ideally, it would be nice to address the admin interface as admin.example.com.
I've thought about using vhost configs to create a reverse proxy from admin.example.com to www.example.com/app however I feel like this is a messy approach.
I've also explored the host option in the @Route annotation within Symfony, however this is also very messy as I need to define this (and a number of supporting default and requirement options) in each controller.

The core reason behind running the same application is that I'd like to have both halves of the application driven by the same database and the same Symfony entities. I understand that I can build two separate applications and this would solve my issue, however this would then create two separate sets of entities between the two projects and ultimately the potential for errors down the track. I would like to avoid having separate applications if I can.
Thanks in advance!

A:

I've come up with a solution to something with this kind issue. Posting my own response in case any one comes across a similar issue and would like to know how I went about it.

As I mentioned there will be an admin control interface and a front end interface. They will both look very different however one will be more application based (admin) and one will be more information centric (front end website).
I have opted to use two separate applications. However making using of the FOSRestBundle I am exposing basic information in the form of a simple API that will be driven to drive a snappy and responsive front end using information from the back end component of the application. The front end doesn't need to be a Symfony application, just something that can render content from the API (either generated server side, or a secondary request post page load via JavaScript - whichever is more fitting).
While this isn't exactly what I was initially envisioning at first, I realise this is the better approach as it would have made the application much more bloated and difficult to maintain over time as the application grew. It will also be rather easy to create a number of simple tests to assure that the data provided by the API is as the front end expects, to avoid any issues as the back end is developed.
Hope this helps anyone!

