I have a Symfony2 core, which is used for domain A and domain B. But, if I update the core, I need to update two times, because I don't know how to configure only one core, with multiple domains with theirs configs/databases.
Suggestions?
Make a copy of the "web" directory into the "public_html" folder on each domain (assuming you are running Apache on Linux)
This "web" directory contains the front controllers of your site (app.php and app_dev.php), locate them and edit them on your favorite text editor. Locate this lines:
require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';
and change the route to the actual relative path where your core is located. It could be something like this:
require_once __DIR__.'/../the_core_is_here/app/bootstrap.php.cache';
require_once __DIR__.'/../the_core_is_here/app/AppKernel.php';
This is flexible, and can be organized as you like, but make sure this two lines have the correct path
Keep in mind that all the assets (JS, CSS, images ...) you include into your HTML are relative to the front controller location, so you will need to link them using the full url of the domain name where they reside or copy them also to the B domain or use assetic
At the end you will have something like:
/
.. home
.. .. DOMAINA
.. .. .. public_html
.. .. .. .. app.php
.. .. .. .. img
.. .. .. .. .. image.png
.. .. DOMAINB
.. .. .. public_html
.. .. .. .. app.php
.. .. .. .. img
.. .. .. .. .. image.png
.. .. the_core_is_here
.. .. .. app
.. .. .. src
.. .. .. bin
.. .. .. vendor
Now you should have 2 entry points for your application. You can even put different CSS and images on each to give them different aspect.
Perhaps you could try using Capifony, it's a deployment script written in ruby
for Symfony
application. I haven't done any setup like what you are trying to achieve, but I use it to deploy both staging & production servers. It can be setup to deploy different instances of the application to one server (eg: different directories), or multiple servers.
Once they are correctly setup, deploying is just a matter of typing:
cap server1 deploy
cap server2 deploy
Everytime you run the command, capifony
will pull the latest code from the repository (eg: git), and deploy it. As a bonus, old versions of the application are also saved on the server should you need to return to previous state.
Here is the sample capifony configuration script just to give you an overview:
# deploy.rb
set :application, "My App"
set :deploy_to, "/var/www/my-app.com"
set :domain, "my-app.com"
set :scm, :git
set :repository, "ssh-gitrepo-domain.com:/path/to/repo.git"
role :web, domain
role :app, domain
role :db, domain, :primary => true
set :use_sudo, false
set :keep_releases, 3
And you can have different configuration scripts, each for a different domain, using the multistage extension for capifony
.
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