E
E
evnuh2014-07-08 12:55:26
CodeIgniter
evnuh, 2014-07-08 12:55:26

How to organize version control of two identical sites?

There was a situation - there are two sites built on the same code base. They will differ, but not significantly. Moreover, both must be supported, respectively, changes in the code should be applied both there and there, but so that the differences in the code do not lead to conflicts. How is it usually done?
Git, CodeIgniter.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Entelis, 2014-07-08
@evnuh

3 branches of code:
the main one and a branch of specific changes for each of the sites.
changes from the main are periodically merged into the branches of sites.
the main thing is to cover the code well with tests)
Or the second option - if the differences are really insignificant, and the situation is not planned to worsen in the future - you can wrap both domains with the same code, and implement branching in the code itself.

P
Pavel Volintsev, 2014-08-23
@copist

You need 3 branches in the repository - core + site1 + site2
in the site1 and site2 repositories do a git submodule core
now site1 and site2 contain the core as part of the code
but this will only work if site1 and site2 use the core but do not modify it. Inheritance, class substitution, configuration through the configuration file is allowed.
For example, the core contains the HttpRequest.php file with the HttpRequest class
And the site1 application requires additional functions in this class
Then there are two possible solutions, depending on what is implemented in the core:
1. Setting up file autoloading
Create a copy of the Site1HttpRequest.php file with the definition of the HttpRequest class in the site1 code
Set up an autoloader for site1 so that the Site1HttpRequest.php file is used when accessing the HttpRequest class definition
2. Locator (dependency inversion)
Create a locator class in the core code to store frequently used instances, which it returns by key name. For example, an entity with the key request is an instance of the HttpRequest class.
In the site1 code, we create the Site1HttpRequest class, which inherits HttpRequest from the core, and expand or redefine the functionality.
In the settings of the locator class for site1, we write that if an instance is required by the request code, then the Site1HttpRequest class should be loaded.
Links and code snippets:
1. git submodules
2. Using the class table in the Yii framework

Yii::$classMap=array(
        'HttpRequest'=>'/path/to/HttpRequest.php', // <-- можно указать другой путь к классу
);
Yii::createWebApplication($config)->run();

3. Application - locator class in the Yii framework
# @file protected/config/main.php
array(
    'components' => array(
         'request' => array(
            'class' => 'HttpRequest', // <-- можно указать другой класс
        ),
    ),
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question