/magephi

PHP CLI application to manage your Magento 2 projects with Docker

MIT LicenseMIT

Magephi

status php symfony GitHub tag (latest by date) GitHub Issues Contributions welcome license

Magephi is a Symfony based PHP CLI designed to manage Magento 2 projects environment.

Its main functionality are the installation/start/stop of your environment but it can also initialize a Magento 2 project with its environment, give you access to services, verify your environment match the prerequisites, import a database etc.

For now Magephi has been only tested on Mac with the environment docker-magento2.

Installation

composer global require fulmenef/magephi

Usage

# List Magephi commands
magephi 

# Execute a specific command
magephi xxxxx

# Display the help message of a specific command
magephi xxxxx --help

# List all available commands (i.e. Symfony included)
magephi list

Demo

demo

Functionality

General

  • magephi prerequisites to check if your system match the prerequisites to use the environment.
  • magephi import to import a database and update the urls.
  • magephi update to update Magephi.

Environment

  • magephi create Initialize a new project with the environment. See here for more details about the command.
  • magephi install to install the environment (build + start).
  • magephi status to give you a quick look on the project status (equivalent to docker-compose ps and mutagen list).
  • magephi start to start the environment.
  • magephi stop to stop the environment.
  • magephi cache to flush Magento and Redis cache.
  • magephi uninstall to fully uninstall the environment. This will remove volumes and container but not the files on your local system.
  • magephi backup|restore Generate or restore a backup of your database and environment configuration.

Docker

  • magephi php|mysql|nginx|redis to connect to containers.
  • magephi build to build the containers. The docker/local/.env file must have been filled before.

Magento

  • magephi magento:install to install Magento after you have installed the environment.

Details

Project initialization

You can initialize a project with the magephi create. If you are in an empty directory, the project will be installed inside it, if not you'll be asked for the project name and a directory with that name will be created and used as work directory.

At the same time as the Magento 2 dependency, some development dependencies are added.

Also, a custom .gitignore is set, you can have a look of the content here.

Composer
Yarn
Example of configuration for Husky and Lint-Staged

The following will run PHPCsFixer and PHPStan on each PHP and PHTML files, Stylelint for each LESS files and Eslint for javascript files each time you run a git commit.

// To be placed at the end of the package.json

"husky": {
    "hooks": {
        "pre-commit": "lint-staged --relative --shell"
    }
},
"lint-staged": {
    "!(app/etc/*).php|*.phtml": [
        "php ./vendor/bin/php-cs-fixer fix --config .php_cs",
        "php ./vendor/bin/phpstan analyze --level=max --no-progress"
    ],
    "app/code/YourVendor/**/*.less|app/design/frontend/YourVendor/**/*.less": [
        "php ./node_modules/.bin/stylelint --fix"
    ],
    "app/code/YourVendor/**/*.js|app/design/frontend/YourVendor/**/*.js": [
        "php ./node_modules/.bin/eslint --fix"
    ]
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

If you would like to see your environment managed by Magephi, please open an issue.

License

MIT