Tags:

The ultimate Magento local development environment

Profile picture of Christoph Maßmann Chris
created on , last updated on Follow me

Time is money and therefore every developer should strive for an optimal setup in which he can operate the fastest. Since I began with Magento in 2008 a lot has changed tool-wise and I am constantly improving to find the optimum Magento local development setup.

The perfect Tooling

Now let's have a look at which software pieces do you need for fast and qualitative development of Magento Extensions:

  • PhpStorm: since many years now the state-of-the-art IDE for PHP, this software is worth every penny and is continually updated every few months
  • Magicento: the plugin that makes PhpStorm incredible useful for Magento by providing auto-completion, automatically generating module structure and many more features.
  • PHP Inspections (EA Extended): also a plugin for PhpStorm that massively supports you in writing correct, clean and effective code. I basically use this in conjunction with the code sniffer and the mess detector (see below)
  • PhpCodesniffer in combination with Magento ECG Coding Standards
  • Php Mess Detector: easily find duplicate code contents before someone other will find it
  • Xdebug with code coverage: run directly in PhpStorm you will get visual feedback about your code coverage
  • while in the good old days you had the Magento installation completely directly on your local PC, then switched to a Vagrant box with Magento and now we arrived at the beautiful container techniques like Docker. I cannot emphasize enough how helpful Docker is in my daily routine, especially when switching between different clients or module developments, Magento versions, etc.
  • modman: this tools was created by one of the Magento gurus to help maintaining magento modules in different installations – very helpful for testing in different PHP/Magento/.. versions
  • n98-magerun: every Magento developer always has to do some repeating stuff like cache-flush, resetting admin password, install specific version with sample data, etc.; this tool is absolutely unbeatable in these things.
  • ngrok is a ideal tool if you have to access your local environment from the outside (like e.g. give test links to your clients, access APIs from third-party-services and so on)
  • a MacBook Pro ;-)

The perfect Docker Setup

As mentioned above Docker is a massive help in easily setting up a local Magento development environment and also switching between different PHP or Magento versions. Below you will find my perfect docker-compose.yml that I use for each Magento project.

The setup has the following features:

  • The Magento Docker image is based on FrankenPHP which is based on the Caddy Webserver bundled together with PHP and boy it is lightening fast - I have never seen a faster development environment!
  • It uses Mailpit to test local email delivery. Mailpit is also perfect in analyzing the email compatibility for different email clients (and there are many!)

Now let's have a look at the Docker Compose file:

version: "3.4"

services:
  franken:
    build: ./frankenphp
    ports:
      - "80:80"
      - "443:443"
    links:
      - "mysql:mysql"
      - "cache:cache"
      - "mailhog:mailhog"
    volumes:
      - ../htdocs/:${WEBSERVER_DOCROOT}/htdocs
      - ../src/:${WEBSERVER_DOCROOT}/src:delegated
      - ../vendor/:${WEBSERVER_DOCROOT}/vendor
      - ./magento/local.xml:${WEBSERVER_DOCROOT}/htdocs/app/etc/local.xml:ro
    environment:
      MAGE_IS_DEVELOPER_MODE: "1"

  mysql:
    image: mariadb:10.6
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MARIADB_AUTO_UPGRADE: 1
    ports:
     - "3306"
    volumes:
      - /var/lib/mysql

  cache:
    image: redis:latest

  mailhog:
    image: axllent/mailpit
    ports:
      - "1025:1025"
      - "8025:8025"

Post Comments to "The ultimate Magento local development environment"

Submit Comment

With the use of this comment form you agree to the saving and processing of your data by this website. More information about the processing of your data can be found in our privacy statement.
Your data will be transmitted securely via SSL.