fulmenef / magephi
PHP toolbox to manage Magento 2 project with a Docker Environment.
Installs: 57
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 2
Forks: 1
Open Issues: 0
Type:application
Requires
- php: ~8.2 || ~8.3 || ~8.4
This package is auto-updated.
Last update: 2025-04-22 16:37:46 UTC
README
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
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
- Docker Magento 2: Docker environment for your project
- PhpStan: Static code analyser for PHP
- PhpStan extension for Magento
- PhpCsFixer: A tool to automatically fix PHP Coding Standards issues
- Security Checker: Command line tool that checks if your application uses dependencies with known security vulnerabilities
- Security Advisories: Composer tool to help to prevent installing packages with know vulnerabilities
Yarn
- Husky: Tool to trigger action on git hooks
- Lint-Staged: Linter to apply checks on staged files, used with Husky.
- Eslint: Static code analyser for Javascript
- Eslint extension for Magento
- Stylelint: Linter for LESS/CSS files
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.