7

3 years ago I was a part of a company that ran magento webshops for many independent customers. What we experienced at the end was that if we wanted to do a change that affects all the shops (bug fix) or an upgrade of magento, we had to do it on a case by case basis.

I would like to get your input on if there is a way to set up a structure that will allow for upgrade all the shops at once and fix common issues for all in a simple way.

Every shop will have the same core, but modules etc might vary. As they each are individual stores.

  • You have many different installs or one install and multiple stores? – brentwpeterson Jan 1 '15 at 20:59
  • Many different installs – David Gulbrandsen Jan 2 '15 at 0:42
  • This is assuming that every shop will be identical and will not have any variations on code correct? – brentwpeterson Jan 2 '15 at 14:23
  • Every shop will have the same core, but modules etc might vary. As they each are individual stores. – David Gulbrandsen Jan 3 '15 at 18:21
  • 1
    You can symlink the core files but you will still have to deal with each individual store. Not sure how much ahead that will get you – brentwpeterson Jan 3 '15 at 23:51
6

I recommend to set up your Magento projects with Composer. Then you can include the Magento core as a dependency and manage it in a single separate repository with all official updates and patches. You could include custom patches there as well but I would rather keep them in another repository.

This only works if you separate core and customization. If you are already using modman, I have good news for you: the transition is easy.

But coming from several monolithic project repositories it will take some initial effort to separate your customizations from the core.

How it works

(Instructions for new project setup)

  1. Create a repository that includes the Magento core and create a composer.json file in it with this content:

    {
        "name": "magento/ce",
        "type": "magento-source",
        "require": {}
    }
    

    You can clone one of the existing mirrors like https://github.com/OpenMage/magento-mirror or https://github.com/firegento/magento which contain all recent community versions including security patches, but you will have to add the composer.json (the important bit is "type": "magento-source", which tells the composer installer that this contains the Magento core).

  2. Create a composer.json file in your projects with this content (replace url_to_your_magento_repo.git with the URL of the repository that we created before (for example git@bitbucket.org:your-company/magento-ce.git)

    {
        "require": {
            "aoepeople/composer-installers": "dev-master",
            "magento/ce": "dev-master"
        }
        "minimum-stability": "dev",
        "repositories": [
            {
                "type": "vcs",
                "url": "url_to_your_magento_repo.git"
            },
            {
                "type": "composer",
                "url": "http://packages.firegento.com"
            }
        ],
        "extra":{
            "installer-paths": {
                "www/" : [ "type:magento-source" ],
                ".modman/{$vendor}_{$name}/" : [ "type:magento-module" ]
            }
        }
    }
    

    This tells composer to install the Magento source to www and Magento modules that you might install with composer to .modman. You can replace "magento/ce": "dev-master" with a specific version or branch. Branches must be prefixed with "dev-".

  3. Run composer install to install the dependencies (i.e. Magento core)

  4. Get modman and run modman init www. Modman is a tool that creates symlinks to keep your modules seperate from the core.

  5. Write all customizations as modules inside of .modman with a modman file that defines the symlinks, and run modman deploy MODULE_NAME to create the symlinks. See modman documentation for details.

  6. Custom modules that you use across several sites can be created as separate repositories similar to the Magento core repository, but with "type": "magento-module". Also they must contain a modman file. After defining such a repository as a dependency and running composer update you will find the module in .modman and can use modman deploy to create the symlinks.

This presentation explains the setup in detail:

Magento with Composer - Marcel Hauri - Meet Magento CH 2014 (Video, 21 min)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.