README.md 4.92 KB
Newer Older
Ketan's avatar
Ketan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
# Magento Composer Installer

This is a fork of the [Magento Composer Installer](https://github.com/magento-hackathon/magento-composer-installer) repo that provides support for Magento 2 components (modules, themes, language packages, libraries and components).

## Usage

In the component's `composer.json`, specify:

*   `type`, type of Magento 2 component.
*   `extra/map`, list of files to move and their paths relative to the Magento root directory.
*   `extra/chmod`, list of permissions that should be set for files.

    **Note**:
    * `extra/map` is required only if your component needs to be moved to a location other than `<Magento root>/vendor`. Otherwise, omit this section.
    * `extra/chmod` is required only if you need to set specific permissions for files.


## Supported Components
The following list explains the use of `type` in `composer.json`.

### Magento Module 
`"type": "magento2-module"`

Installation location: Default vendor directory or as defined in `extra/map`

Example:

```json
{
    "name": "magento/module-core",
    "description": "N/A",
    "require": {
        ...
    },
    "type": "magento2-module",
    "extra": {
        "map": [
            [
                "*",
                "Magento/Core"
            ]
        ]
    }
}
```

Final location is `<magento root>/app/code/Magento/Core`

### Magento Theme 
`"type": "magento2-theme"`

Installation location: `app/design`

Example:
```json
{
    "name": "magento/theme-frontend-luma",
    "description": "N/A",
    "require": {
        ...
    },
    "type": "magento2-theme",
    "extra": {
        "map": [
            [
                "*",
                "frontend/Magento/luma"
            ]
        ]
    }
}
```

Final location is `<magento_root>/app/design/frontend/Magento/luma`

### Magento Language Package
`"type": "magento2-language"`

Installation location: `app/i18n`

Example:
```json
{
    "name": "magento/language-de_de",
    "description": "German (Germany) language",
    "require": {
        ...
    },
    "type": "magento2-language",
    "extra": {
        "map": [
            [
                "*",
                "Magento/de_DE"
            ]
        ]
    }
}
```

Final location is `<magento_root>/app/i18n/Magento/de_DE`

### Magento Library
`"type": "magento2-library"`

Support for libraries located in `lib/internal` instead of in the `vendor` directory.

Example:

```json
{
    "name": "magento/framework",
    "description": "N/A",
    "require": {
       ...
    },
    "type": "magento2-library",
    "extra": {
        "map": [
            [
                "*",
                "Magento/Framework"
            ]
        ]
    }
}
```

Final location is `<magento_root>/lib/internal/Magento/Framework`

### Magento Component
`"type": "magento2-component"`

Installation location: Magento root directory

Example:

```json
{
    "name": "magento/migration-tool",
    "description": "N/A",
    "require": {
        ...
    },
    "type": "magento2-component",
    "extra": {
        "map": [
            [
                "*",
                "dev/tools/Magento/Tools/Migration"
            ]
        ]
    }
}
```

Final location is `<magento_root>/dev/tools/Magento/Tools/Migration`


## Autoload
After handling all Magento components, `<magento_root>/app/etc/vendor_path.php` specifies the path to your `vendor` directory.

This information allows the Magento application to utilize the Composer autoloader for any libraries installed in the `vendor` directory. The path to `vendor` varies between particular installations and depends on the `magento_root` setting for the Magento Composer installer. That's why it should be generated for each installation.

You must run `composer install` to install dependencies for a new application or `composer update` to update dependencies for an existing application.

## Deployment Strategy
The Magneto Composer Installer uses the `copy` deployment strategy. It copies each file or directory from the `vendor` directory to its designated location based on the `extra/map` section in the component's `composer.json`.

There are [other deployment strategies](https://github.com/magento/magento-composer-installer/blob/master/doc/Deploy.md) that could be used; however, we don't guarantee that any of them will work.

## Usage `extra/chmod`

The following example shows how you can set specific permissions for files.

Example:

```json
{
    "name": "magento/module-sample",
    "description": "N/A",
    "require": {
        ...
    },
    "type": "magento2-module",
    "extra": {
         "chmod": [
            {
                "mask": "0755",
                "path": "bin/magento"
            },
            {
                "mask": "0644",
                "path": "some_dir/file.jpg"
            }
        ]
    }
}
```

`mask` is a bit mask for chmod command

`path` is a path to file relative to the Magento root folder

# Notes
- The extra->magento-root-dir option is no longer supported. It displays only to preseve backward compatibility.