PHPackages                             maxbucknell/eisenhardt - 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. [DevOps &amp; Deployment](/categories/devops)
4. /
5. maxbucknell/eisenhardt

ActiveLibrary[DevOps &amp; Deployment](/categories/devops)

maxbucknell/eisenhardt
======================

Batteries not included Docker environment for Magento 2.

0.2.2(9y ago)3191[1 PRs](https://github.com/maxbucknell/eisenhardt/pulls)MITPHP

Since May 5Pushed 7y agoCompare

[ Source](https://github.com/maxbucknell/eisenhardt)[ Packagist](https://packagist.org/packages/maxbucknell/eisenhardt)[ RSS](/packages/maxbucknell-eisenhardt/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (2)Versions (24)Used By (0)

Eisenhardt
==========

[](#eisenhardt)

A "batteries not included" best practice development environment for Magento 2, based on Docker.

By this, we mean that this only contains the server configuration, and does no magic around installing Magento. We found that we needed a best practice development environment for projects we already had. As such, Eisenhardt is not picky about how your projects are configured. You just need to set it up in the root of your project.

Eisenhardt is a very thin wrapper around Docker Compose.

Installation
------------

[](#installation)

### Dependencies

[](#dependencies)

- [Docker](https://docs.docker.com/engine/installation/linux/)
- [Composer](https://getcomposer.org/download/) (and PHP)
- [mkcert](https://github.com/FiloSottile/mkcert)

Install via Composer!

```
composer global require maxbucknell/eisenhardt
```

Getting Started
---------------

[](#getting-started)

This will walk you through setting up a clean installation of Magento. To use Eisenhardt on an existing project, see the section below on that topic.

First of all, create a Magento 2 project

```
composer create-project \
  --repository-url=https://repo.magento.com/ \
  magento/project-community-edition:~2.1.0 \
  --no-install \
  test-eisenhardt
```

This creates a Magento 2 base project in the `test-eisenhardt` directory. Switch to it, and set up Eisenhardt:

```
eisenhardt init test-eisenhardt.loc
eisenhardt start
```

Now we can begin to install Magento. First step is the dependencies:

```
eisenhardt run -- composer install
```

Now is probably a good time to make sure the permissions are correct:

```
eisenhardt fix-permissions
```

And make sure the database exists:

```
eisenhardt run -- mysql -hdatabase -uroot -proot
MySQL [(none)]> create database showoff;
```

And then the installation. The following command will do it all, but feel free to change anything if you need to.

```
eisenhardt run -- n98-magerun2 setup:install \
  --backend-frontname="admin" \
  --db-host="database" \
  --db-name="showoff" \
  --db-user="root" \
  --db-password="root" \
  --http-cache-hosts="varnish:6081" \
  --base-url="http://test-eisenhardt.loc/" \
  --language="en_US" \
  --timezone="UTC" \
  --currency="EUR" \
  --admin-user="magento.admin" \
  --admin-password="password123" \
  --admin-email="magento.admin@example.com" \
  --admin-firstname="Magento" \
  --admin-lastname="Admin"
```

If you are running Enterprise, you can configure the Message Queue framework with these arguments:

```
  --amqp-host="rabbitmq" \
  --amqp-port="5672" \
  --amqp-user="guest" \
  --amqp-password="guest" \
  --amqp-virtualhost="/" \

```

Now there are some final setup tasks, which are optional but encouraged to get a quick environment:

```
eisenhardt run -d -- n98-magerun2 setup:static-content:deploy
eisenhardt run -- n98-magerun2 cache:flush
eisenhardt run -- n98-magerun2 setup:di:compile
```

After this, your Magento 2 installation should be ready to use, but you won't be able to access it. To do this, run `eisenhardt info`, and copy the IP address of the `webserver` container. Add an entry to your hosts file:

```
 test-eisenhardt.loc

```

If you visit `test-eisenhardt.loc/` in your browser, you should see the home page. Log into the admin with `magento.admin` and `password123`.

To see more details and available options, please check out the rest of the documentation.

```
eisenhardt init
eisenhardt start
eisenhardt info
# Edit your /etc/hosts file to point your base URL to the IP address of the webserver
# Edit your app/etc/env.php to point your database at `database`.
eisenhardt run -- n98-magerun2 db:import
```

Command Reference
-----------------

[](#command-reference)

### `eisenhardt init`

[](#eisenhardt-init)

Bootstrap a new Eisenhardt project, or update an existing one.

This command should be run from the root of your Magento 2 installation.

### `eisenhardt start`

[](#eisenhardt-start)

Start the Eisenhardt environment, and make it ready for use.

This command searches up its directory tree for a Eisenhardt environment, so can be run from any directory inside your Magento 2 installation.

#### Options

[](#options)

FlagDescription`-p`, `--map-ports`Map ports of Eisenhardt environment to host. By default, this does not happen, and Eisenhardt containers are accessible only from their IP addresses. Use this if you don't like editing your hosts file, or if you are running Docker on a remote machine, including a Mac or Windows computer.### `eisenhardt info`

[](#eisenhardt-info)

Print some useful information about the Eisenhardt environment.

This command searches up its directory tree for a Eisenhardt environment, so can be run from any directory inside your Magento 2 installation.

### `eisenhardt run`

[](#eisenhardt-run)

Run a command inside the Eisenhardt environment.

There are many administrative tasks that require integration with the Magento installation. This includes (but is not limited to):

- Running a database dump.
- Running a cron command to debug.
- Installing dependencies via Composer.

You can do this by `exec`ing a command inside the PHP container, but it is not the best idea. That will force you to install various command line tools inside the app container.

`eisenhardt run` circumvents this by creating a new container, and injecting it into the Eisenhardt environment's network, and mounting the volumes from the appserver. It then runs an arbitrary command, and removes itself.

The container used is `maxbucknell/console`, and has an identical PHP configuration to the appservers. Along with that, it also has a variety of useful tools preinstalled, including:

- MySQL client (`n98-magerun2 db:con`)
- Redis client (`redis-cli -h cache`)
- Composer (`composer`)
- N98-Magerun2 (`n98-magerun2`)
- Git (`git`)
- Curl (`curl`)
- Vim (`vim`)
- PV
- Liquidprompt
- Node.js (with npm **and** Yarn)

A lot of configuration is also passed from your host to the container. In particular, Git configuration (including aliases), as well as SSH Agent sockets, and Composer caches.

If you are running a command that takes flags as arguments, these flags will be interpreted by the `eisenhardt` utility. To avoid this, you can quote your command, or place your command after a `--`, like so:

```
# Prints the Magerun help, not eisenhardt help
eisenhardt run -- n98-magerun2 --help
```

See the page of that image for more details.

#### Options

[](#options-1)

FlagDescription`-x`, `--debug`Run the container with Xdebug installed and enabled. If you want to debug a cron task, this is the way to do it.### `eisenhardt fix-permissions`

[](#eisenhardt-fix-permissions)

Set permissions to something approaching correct for a Magento 2 installation.

By correct, we mean the following:

- All files and folders are owned by the host user (that's you!)
- All files and folders have the group `eisenhardt-www (10118)
- All files have permissions `744` (`rwxr--r--`)
- All folders have permissions `755` (`rwxr-xr-x`)
- All folders are set to "sticky", which means that new files created within them inherit the group and permissions settings.
- `var/` and `pub/` have write permissions on group.
- `bin/magento` is made executable.

This command can take a while to run, since it touches a lot of files. If you have `core.fileMode` set to `true` in your Git configuration, this can generate changes on your files. You can either commit these (they're good permissions, Brent), or you can tell Git not to track permissions.

### `eisenhardt stop`

[](#eisenhardt-stop)

Stop the Eisenhardt environment, as if you turned off your servers.

Configuration for Existing Environments
---------------------------------------

[](#configuration-for-existing-environments)

If you are setting up an existing Magento 2 installation with Eisenhardt, the only thing you need to change is `env.php`.

Start off by running `eisenhardt init` in the project root, and then `eisenhardt start`. You will need to add a hosts entry as per the Getting Started instructions. Then set the `env.php` parameters correctly.

The following `env.php` should work on pretty much all Eisenhardt installations. Feel free to copy verbatim, or take the relevant parts.

Once done, the database will need to be imported. Create the database first, with `eisenhardt run -- n98-magerun2 db:create`, and then import from a dump with:

```
# path/to/db.sql needs to be within your project root or Docker will not find it.
eisenhardt run -- n98-magerun2 db:import path/to/db.sql
```

A quick cache flush with `eisenhardt run -- n98-magerun2 c:f` and you should be good to go.

> Note: that we have queue configuration in here, for the Enterprise Message Queue framework. If you are using Community edition, you remove it, but it's probably not going to cause any damage by remaining.

```
