PHPackages                             netresearch/akeneo-bootstrap - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. netresearch/akeneo-bootstrap

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

netresearch/akeneo-bootstrap
============================

Bootstrap Akeneo before run

1.6.18(8y ago)4343[1 issues](https://github.com/netresearch/docker-akeneo-app/issues)PHPCI passing

Since Jan 30Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/netresearch/docker-akeneo-app)[ Packagist](https://packagist.org/packages/netresearch/akeneo-bootstrap)[ RSS](/packages/netresearch-akeneo-bootstrap/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

[![packagist](https://camo.githubusercontent.com/1c6f55e473ba5a9b0c8708536a9ecdf39ddf4c96e250b7c2d1323cb46acd1b17/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e657472657365617263682f616b656e656f2d626f6f7473747261702e7376673f7374796c653d666c6174)](https://packagist.org/packages/netresearch/akeneo-bootstrap)[![docker pulls](https://camo.githubusercontent.com/474d390b6555d33653cdfcb1fcaf7f86c8ff664b43a6c4cc34f035c5b5b13e0b/68747470733a2f2f696d672e736869656c64732e696f2f646f636b65722f70756c6c732f6e657472657365617263682f616b656e656f2d6170702e7376673f7374796c653d666c6174)](https://hub.docker.com/r/netresearch/akeneo-app/tags/)[![travis](https://camo.githubusercontent.com/97685248dd6ebf7ff5b088a4558d77282915046dc46eaca90fdf6c89d9379e67/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f6e657472657365617263682f646f636b65722d616b656e656f2d6170702e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/netresearch/docker-akeneo-app)

---

This is

1. The composer package [netresearch/akeneo-bootstrap](https://packagist.org/packages/netresearch/akeneo-bootstrap) to bootstrap Akeneo projects and configure them from other packages rather than via their own config files (better updatability).
2. The Docker image [netresearch/akeneo-app](https://hub.docker.com/r/netresearch/akeneo-app/) providing a ready built [Akeneo PIM](https://www.akeneo.com/) project, ready to run with MongoDB and optimized for best possible updatability utilizing [akeneo-bootstrap](#composer-package-akeneo-bootstrap).

Contents
========

[](#contents)

- [Composer package](#composer-package)
    - [`akeneo-project`](#akeneo-project)
        - [Installation](#installation)
        - [Creating a project](#creating-a-project)
        - [Up/downgrading a project](#updowngrading-a-project)
    - [`akeneo-bootstrap`](#akeneo-bootstrap)
        - [Environment variables](#environment-variables)
        - [Customizing Akeneo from other packages](#customizing-akeneo-from-other-packages)
            - [Adding bundles](#adding-bundles)
            - [Adding configs](#adding-configs)
            - [Adding routings](#adding-routings)
            - [Adding custom bootstraps](#adding-custom-bootstraps)
- [Docker image](#docker-image)
    - [Run](#run)
    - [Environment variables](#environment-variables)
    - [Customize Akeneo](#customize-akeneo)

Composer package
================

[](#composer-package)

The common way to install Akeneo is to create a composer project from [akeneo/pim-community-standard](https://packagist.org/packages/akeneo/pim-community-standard) which has major drawbacks:

1. Akeneo [still](https://www.akeneo.com/forums/topic/please-add-akeneopim-community-dev-at-packagist/) didn't publish its core package to packagist which thus needs to be provided as composer repository. As the corresponding github repository has tons of branches and tags using it for composer is firstly damn slow and secondly makes composer reach the github API limits which can hardly be handled in any environment where you don't want to expose your github API key. Also there is no way for other packages to require *akeneo/pim-community-dev* as long as the github repository is not added in the root composer.json.
2. `composer create-project` naturally creates the project once - if you want to update to a newer version of the original project there is no easy way to this with composer. Rather you'll be forced to update the copied sources following the upgrade instructions which is - at least for us - not what we would
3. If you need to change Akeneo configs, routings or add Bundles you have to touch the code generated by `composer create-project` which makes updating even harder.

You could also download a ready built Akeneo project - the updating issues however remain.

This package provides a mechanism to work around the problems above:

1. It provides the plain shell script [akeneo-project](#akeneo-project) to create or upgrade an Akeneo project.
2. It provides the command line application [akeneo-bootstrap](#akeneo-bootstrap) which generates configuration in the project from according instructions in installed packages and sets Akeneo up for running.

It replaces [incenteev/parameter-handler](https://github.com/Incenteev/ParameterHandler) which is registered for composers post-install-cmd and post-update-cmd and thus is invoked automatically to generate the AppKernel, configs and routings when packages are installed (steps 1 - 4 of [akeneo-bootstrap](#akeneo-bootstrap) command).

`akeneo-project`
----------------

[](#akeneo-project)

Use the `akeneo-project` script to create or upgrade an Akeneo project. It also installs netresearch/akeneo-bootstrap into the project (which automatically invokes 1 - 4 of the [akeneo-bootstrap](#akeneo-bootstrap) command).

### Installation

[](#installation)

The script is standalone but as it requires PHP and composer anyway you better install it with composer:

```
composer global require netresearch/akeneo-bootstrap
akeneo-project -h
```

### Creating a project

[](#creating-a-project)

```
akeneo-project create -v 1.7.6
```

### Up/downgrading a project

[](#updowngrading-a-project)

```
akeneo-project upgrade -v 1.7.6
```

`akeneo-bootstrap`
------------------

[](#akeneo-bootstrap)

The `akeneo-bootstrap` command is shipped with the composer package `netresearch/akeneo-bootstrap` which is also installed by [akeneo-project](#akeneo-project). It executes the following steps:

1. Generate the AppKernel (overriding, not replacing the original Akeneo AppKernel) with bundles required by any installed packages
2. Generate (local) config and routing files invoking resources required by any installed packages
3. Generate the parameters.yml from environment variables
4. Fix PIM, ORO and Symfony requirements (adjust paths)
5. Clear cache if required by any of the previous steps
6. Boot the kernel
7. Wait for the database to be up
8. Ensure the Akeneo installation (check requirements, install / upgrade DB, dump assets)
9. Set export/import paths
10. Link static directories if required (Akeneo sometimes doesn't use the configured directories but fixed paths like `app/logs` - this step symlinks those directories to the configured ones like [LOG\_DIR](#environment-variables))
11. chown the directories required to be writable from web (see [WEB\_USER](#environment-variables))

### Environment variables

[](#environment-variables)

[akeneo-bootstrap](#akeneo-bootstrap) uses the following environment variables to configure Akeneo:

VariableDescriptionDefaultDATABASE\_DRIVERThe database driverpdo\_mysqlDATABASE\_HOSTThe database host namelocalhostDATABASE\_PORTThe database port3306DATABASE\_NAMEName of the databaseakeneo\_pimDATABASE\_USERDatabase user nameakeneo\_pimDATABASE\_PASSWORDDatabase users passwordakeneo\_pimLOCALEThe locale for AkeneoenSECRETEntropy string for security related operations`hash('sha256', uniquid())`PIM\_CATALOG\_PRODUCT\_STORAGE\_DRIVERSet this to `doctrine/mongodb-odm` when you want to use MongoDB-MONGODB\_SERVERIf set (e.g. to `mongodb://mongodb:27017`), the DoctrineMongoDBBundle will automatically activated.-MONGODB\_DATABASEIf you use MongoDb you must provide a database name, which will be used for the product collections-CACHE\_DIRPath for symfony caches/var/cache/akeneoLOG\_DIRPath for the Akeneo logs/var/log/akeneoUPLOAD\_DIRPath where uploads should be stored/var/opt/akeneo/uploads/productCATALOG\_STORAGE\_DIRcatalog\_storage\_dir/var/opt/akeneo/file\_storage/catalogARCHIVE\_DIRarchive\_dir/var/opt/akeneo/archiveEXPORT\_PATHSet this to change the directory to where exports should go./var/opt/akeneo/exportsIMPORT\_PATHSet this to change the directory from where imports should be read./var/opt/akeneo/imports\*\_PATHSet this with the asterisk replaced by the job name in upper case (e.g. CATEGORY\_IMPORT\_PATH) to change the file path for a particular job (overrides EXPORT\_PATH or IMPORT\_PATH for this job)-WEB\_USERUser name to be set as owner for directories that need to be writable by Akeneo from Webwww-data.www-dataPARAMETER\_\*Any parameter (e.g. from pim\_parameters.yml) which is NOT one of the above (f.e. `PARAMETER_INSTALLER_DATA="/opt/acme/fixtures"` to [use another dataset](https://docs.akeneo.com/1.7/cookbook/setup_data/customize_dataset.html)-USE\_FIXTURE\_PATHSSet this to use configured import and export paths from fixture files. All other configured ...\_PATH will ignored.-The configuration via environment variables was chosen because the package is primarily targeted at installations in Docker containers. If you don't use such and don't want to clutter your environment variables with the above, you could put them into an [.env file](https://docs.docker.com/compose/env-file/) and run [akeneo-bootstrap](#akeneo-bootstrap) and composer commands like this:

```
eval $(cat .env) composer update
```

Customizing Akeneo from other packages
--------------------------------------

[](#customizing-akeneo-from-other-packages)

[akeneo-bootstrap](#akeneo-bootstrap) will scan all installed packages for settings in their composer.json allowing you to register Bundles, configs, routings and custom bootstrap steps to customize Akeneo like so:

```
{
   "name": "acme/akeneo-config",
   "version": "1.0.0",
   "require": {
       "akeneo-labs/custom-entity-bundle": "1.10.*"
   },
   "extra": {
       "netresearch/akeneo-bootstrap": {
            "generate": [
                "Acme\\AkeneoConfig\\Bootstrap\\Generate"
            ],
            "boot": [
                "Acme\\AkeneoConfig\\Bootstrap\\Boot"
            ],
            "bundles": [
                { "class": "Pim\\Bundle\\CustomEntityBundle\\PimCustomEntityBundle" }
            ],
            "routing": {
                "pim_customentity": {
                    "resource": "@PimCustomEntityBundle/Resources/config/routing.yml",
                    "prefix": "/reference-data"
                }
            }
        }
    }
}
```

After installing or updating this package *akeneo-bootstrap* will automatically update the Kernel and local configuration and routing files to add the configured resources.

*Please note* that changes to this composer.json files only take effect when the package is actually updated or installed - if you only change it in the vendor package nothing will happen.

### Adding bundles

[](#adding-bundles)

Bundles are to be registered as objects in an array in `extra.netresearch/akeneo-bootstrap.bundles` in your composer.json. Each of them must have a `class` property containing the bundle class and can have a `env` property containing an array of or an comma separated string with environment names:

```
{
   "name": "acme/akeneo-config",
   "version": "1.0.0",
   "extra": {
       "netresearch/akeneo-bootstrap": {
            "bundles": [
                {
                    "class": "Acme\\Bundle\\AllEnvsBundle"
                },
                {
                    "class": "Acme\\Bundle\\ProdOnlyBundle",
                    "env": "prod"
                },
                {
                    "class": "Acme\\Bundle\\DevAndTestOnlyBundle",
                    "env": ["dev", "test"]
                }
            ]
        }
    }
}
```

**Note** that *all* packages are scanned for this. This allows you to require a single package in the project which requires other packages that contain such configuration as well.

### Adding configs

[](#adding-configs)

Config files are to be registered as objects in an array in `extra.netresearch/akeneo-bootstrap.config` in your composer.json. Each of them must have a `resource` property containing the file path and can have a `env` property containing an array of or an comma separated string with environment names:

```
{
   "name": "acme/akeneo-config",
   "version": "1.0.0",
   "extra": {
       "netresearch/akeneo-bootstrap": {
            "config": [
                {
                    "resource": "../../vendor/acme/akeneo-config/Resources/config/general.yml"
                },
                {
                    "resource": "../../vendor/acme/akeneo-config/Resources/config/prod.yml",
                    "env": "prod"
                },
                {
                    "resource": "../../vendor/acme/akeneo-config/Resources/config/dev.yml",
                    "env": ["dev", "test"]
                }
            ]
        }
    }
}
```

### Adding routings

[](#adding-routings)

Routing files are to be registered as objects in an object in `extra.netresearch/akeneo-bootstrap.routing` in your composer.json. Each of them must have a `resource` property containing the file path and can have a `env` property containing an array of or an comma separated string with environment names. The keys are the keys under which they are registered in the routing\_local.yml's:

```
{
   "name": "acme/akeneo-config",
   "version": "1.0.0",
   "extra": {
       "netresearch/akeneo-bootstrap": {
            "routing": {
                "all_envs": {
                    "resource": "@AllEnvsBundle/Resources/config/routing.yml"
                },
                "prod": {
                    "resource": "../../vendor/acme/akeneo-config/Resources/config/routing_prod.yml",
                    "env": "prod"
                },
                "test": {
                    "resource": "../../vendor/acme/akeneo-config/Resources/config/routing_dev.yml",
                    "env": ["dev", "test"]
                }
            }
        }
    }
}
```

### Adding custom bootstraps

[](#adding-custom-bootstraps)

There are two scopes of bootstraps: **generate** (Akeneo/DB not necessarily initialized; invoked after `composer update/install` and from `./bin/akeneo-bootstrap`) and **boot** (Akeneo/DB ready to run, invoked only from `./bin/akeneo-bootstrap` right after `generate`). Custom bootstrap classes can be registered for each of those scopes as array of class names in `extra.netresearch/akeneo-bootstrap.{SCOPE}` in your composer.json. Each of those classes have to implement `\Netresearch\AkeneoBootstrap\Bootstrap\BootstrapInterface`.

```
{
   "name": "acme/akeneo-config",
   "version": "1.0.0",
   "extra": {
       "netresearch/akeneo-bootstrap": {
            "generate": [
                "Acme\\AkeneoConfig\\Bootstrap\\Generate"
            ],
            "boot": [
                "Acme\\AkeneoConfig\\Bootstrap\\Boot"
            ]
        }
    }
}
```

A bootstrap could for instance look like this:

```
