Skip to content

Latest commit

 

History

History
404 lines (291 loc) · 13.5 KB

README.md

File metadata and controls

404 lines (291 loc) · 13.5 KB

Build Status Dependency Status Reference Status Bountysource

Magento Composer Installer

![Gitter](https://badges.gitter.im/Join Chat.svg)

Dart Mosaic

The purpose of this project is to enable composer to install Magento modules, and automatically integrate them into a Magento installation.

We strongly recommend you to also read the general composer documentations on getcomposer.org

Also you should see Using composer correctly (confoo) by Igor Wiedler

Project Details

This project only covers the custom installer for composer. If you have problems with outdated versions, need to install magento connect modules or similar, you need to look for packages.firegento.com

support contacts

If you have problems please have patience, as normal support is done during free time.
If you are willing to pay to get your problem fixed, communicate this from the start to get faster responses.

If you need consulting, support, training or help regarding Magento and Composer, you have the chance to hire one of the following people/companies.

other support contacts

  • irc: freenode the channels #magento-composer #magento-reddit and for german speaking people #magento-de
  • twitter: @firegento

Known issue

  • Error message: Fatal error: Call to undefined method MagentoHackathon\Composer\Magento\Installer::setDeployManager() happens when you update from 1.x to 2.x, as we switched from pure installer to plugin.

Solution: remove the vendor directory and the composer.lock and do a fresh install.

Known issues

When upgrading from 1.x to 2.x

The update from 1.x to 2.x has to be done with no plugins as otherwise a fatal error will be triggered (which does not hurt, just run the update again and it runs through).

  • Error message: Fatal error: Call to undefined method MagentoHackathon\Composer\Magento\Installer::setDeployManager()

To prevent this error, upgrade only magento-composer-installer first:

composer update --no-plugins --no-dev "magento-hackathon/magento-composer-installer"

Fallback Solutions:

  1. execute composer install two times.
  2. remove the vendor directory and composer.lock and do a fresh install.

Timeouts and slow downloading.

Mostly caused by outtages of Github, Repositories or the Internet. This is a common problem with having all packges remote.

For all of this Issues you can make use of the commercial Toran Proxy. It also allows hosting of private packages and speeds up the whole downloading process.

Another alternative is to look into Satis, bare git mirrors and repository aliasing.

Another way to speedup downloads over ssh(also interesting for satis users) is to improve your ssh configs. At least for newer versions of openSSH you can add the following to your .ssh/config to reuse previous connections.

Host * 
    ControlPath ~/.ssh/controlmasters/%r@%h:%p
    ControlMaster auto
    ControlPersist 10m

also you need to create the controlmasters directory:

mkdir ~/.ssh/controlmasters
chmod go-xr ~/.ssh/controlmasters

further information can be found on wikibooks

Usage

See below for a generic instruction on how to install composer if you aren't familiar with it.

Install the Magento-Core and initialize your project

If you want to setup your project from the scratch, you can require the magento/core package from the public Magento module repository and have your magento-root-dir set up automatically. It is essential that the Magento core packages type is defined as "magento-core" (as given on magento/core).

{
    "require": {
        "magento/core": "1.9.0.1"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "http://packages.firegento.com"
        }
    ],
    "extra":{
        "magento-root-dir": "htdocs/"
    }
}

Install a module in your project

If you want to use the public Magento module repository, set up your root composer.json in your project like this:

{
    "require": {
        "your-vendor-name/module-name": "*",
        "magento-hackathon/magento-composer-installer": "*"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "http://packages.firegento.com"
        }
    ],
    "extra":{
        "magento-root-dir": "htdocs/"
    }
}

If you want to use a github/git/svn/etc repository, set up your root composer.json in your project like this:

{
    "require": {
        "magento-hackathon/magento-composer-installer":"*",
        "the-vendor-name/the-module-name": "*"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/magento-hackathon/magento-composer-installer"
        },
        {
            "type": "vcs",
            "url": "the/github/or/git/or/svn/etc/repository/uri-of-the-module"
        }
    ],
    "extra":{
        "magento-root-dir": "htdocs/"
    }
}

Notes:

  1. More information about VCS repositories can be found at getcomposer.org

Change the Vendor/Name of your Module

sometimes it will happen, that you change the name or the vendor of a package. For example you developed a module in your own namespace and later moved it to an organization, or you moved it from one to another organization. In this cases you should change your composer.json a bit to make it for users easier. Look for the replace statement

{
    "name": "your-new-vendor-name/module-name",
    "type": "magento-module",
    "license":"OSL-3.0",
    "description":"A short one line description of your module",
    "authors":[
        {
            "name":"Author Name",
            "email":"[email protected]"
        }
    ],
    "replace": {
        "your-vendor-name/module-name":"*"
    }
}

Custom Magento module location

By default all magento-modules packages will be installed in the configured "vendor-dir" (which is "vendor" by default). The package name will be used as a directory path and if there is a "target-dir" configured this will also be appended. This results in packaged being installed in a path like this one: vendor/colinmollenhour/cm_diehard.

Originally modman packages "live" in a directory called ".modman". This directory can be inside your htdocs directory, next to it or where ever you want it to be.

If you want magento-composer-installer to install your Magento extensions in a custom location, this can be configured as follows:

{
    ...
    "extra":{
        "magento-root-dir": "htdocs/",
        "modman-root-dir": ".modman"
    }
    ...
}

Make sure the .modman directory exists before updating. There is a fallback in place that will try to find the directory relative to your vendor dir if it wasn't found in the first place.

If you want to still use the original modman script, too, and if your modman-root-dir configuration is not "htdocs/.modman" you'll need a ".basedir" file inside ".modman" that specifies where to find the htdocs folder (see the modman documentation)

Should you choose to only use the original modman script to deploy packages, you will not want to have the magento-composer-installer deploy the packages. So this can be disabled:

{
    ...
    "extra":{
        "magento-root-dir": "htdocs/",
        "modman-root-dir": ".modman",
        "magento-deploystrategy": "none"
    }
    ...
}

Auto add files to .gitignore

If you want to have the deployed files automatically added to your .gitignore file, then you can just set the auto-append-gitignore key to true:

{
    ...
    "extra":{
        "magento-root-dir": "htdocs/",
        "auto-append-gitignore": true
    }
    ...
}

The .gitignore file will be loaded from the current directory, and if it does not exist, it will be created. Every set of module files, will have a comment above them describing the module name for clarity.

Multiple deploys will not add additional lines to your .gitignore, they will only ever be added once.

Testing

First clone the magento-composer-installer, then install the dev-stuff:

./bin/composer.phar install --dev

then run vendor/bin/phpunit in project-root directory.

Note: Windows users please run phpunit with Administrator permissions.

How to overwrite dependencies

We don't want to use always the official repositories for specific dependencies. For example for development purpose or use versions with custom patches.

For this case you have the repositories section inside your project composer.json Here you can define own package composer.json for specific dependencies by the package name.

This example shows how to use a local git projects local-master branch which even works without a composer.json inside and a project in VCS with existing composer.json, which is not yet on packagist.

{
   ...
   "repositories": [
       {
          "type": "package",
          "package": {
             "name": "magento-hackathon/magento-composer-installer",
             "version": "dev-master",
             "type": "composer-installer",
             "source": {
                "type": "git",
                "url": "/public_projects/magento/magento-composer-installer/",
                "reference": "local-master"
             },
             "autoload": {
                "psr-0": {"MagentoHackathon\\Composer\\Magento": "src/"}
             },
             "extra": {
                "class": "\\MagentoHackathon\\Composer\\Magento\\Installer"
             }
          }
       }
    ]
}

Installation of composer

1. Install PHP-Composer

On Linux/Mac

Go to your project root directory and run:

mkdir bin
curl -s https://getcomposer.org/installer | php -- --install-dir=bin

On Windows

Please take a look at http://getcomposer.org/doc/00-intro.md#installation-windows

Creation of symbolic links requires the SeCreateSymbolicLinkPrivilege (“Create symbolic links”), which is granted only to administrators by default (but you can change that using security policy).

To change the policies:

  • Launch secpol.msc via Start or Start → Run.
  • Open Security Settings → Local Policies → User Rights Assignment.
  • In the list, find the "Create symbolic links" item, which represents SeCreateSymbolicLinkPrivilege. Double-click on the item and add yourself (or the whole Users group) to the list.

(Seen at http://superuser.com/questions/124679/how-do-i-create-an-mklink-in-windows-7-home-premium-as-a-regular-user#125981)

2. Download composer.json template

See Usage.

3. Install Magento modules via composer

php bin/composer.phar install

Further Information

External Links

Core Contributors

  • Daniel Fahlke aka Flyingmana (Maintainer)
  • Jörg Weller
  • Karl Spies
  • Tobias Vogt
  • David Fuhr
  • Amir Tchavoshinia
  • Vinai Kopp (Maintainer)

Thank You

There are a few companies we want to thank for supporting this project in one way or another.

#####digital.manufaktur GmbH

Teached me(Flyingmana) most I know about Magento and paid my participation for the hackathon were the installer got created.

#####melovely

Support me(Flyingmana) as my current employer very much in my work on everything composer related.