Our Symfony application is currently one application, that will soon require ability to have multiple sites point to the same Symfony core and have slightly different functionality based on which site it is currently on.
As an example we might have a banner showing on one site but not another. Another example is a payment option that will be enabled/disabled on the different sites. Or another one is different fields on a form on the different sites.
Has anybody had experience structuring Symfony application in this way?
If you want to "theme" your application you can use the LiipThemeBundle, it really works well. For the features activation/deactivation you also have the FeatureToggleBundle bundle (quiet recent).
You could also implement a basic helper like this:
/**
* Check if a feature is activated.
*
* @param string $feature Name of the feature
*
* @throws AccessDeniedHttpException
*/
protected function checkFeature($feature)
{
$features = $this->container->getParameter('app.features')
if (!$features[$feature]) {
throw new AccessDeniedHttpException();
}
}
...
$this->checkFeature('contact_form');
With this kind of configuration:
app.features:
contact_form: false
You have to know that using kernel event listener you can do most of the work.
You can in a 'CoreBundle' for example refer the user to a different template depending on the domain name where he is, using the kernel.request
event.
So in your situation it would be easy for a site to showing a banner in a site but not another.
You can look this article that explains it :
Twig templating using event listener
Yess thats the advantage of symfony
symfony use the kernel connected with routing and controller and then response is being created.
If you want to use multiple applications in symfony you can do this very easily and that is an advantage of symfony.For this you just need to add some routing and everything will be done automatically.
You can use symfony form class to add forms and append them to other pages with required field without creating whole form again.
If you want to add or remove some features on/off you can just do this by app
class or by creating different controllers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With