Skip to content

feat!: add MageForge bind-mount setup and dependency management#198

Open
dermatz wants to merge 6 commits into
mainfrom
install-module-deps-local-dev
Open

feat!: add MageForge bind-mount setup and dependency management#198
dermatz wants to merge 6 commits into
mainfrom
install-module-deps-local-dev

Conversation

@dermatz

@dermatz dermatz commented Jun 8, 2026

Copy link
Copy Markdown
Member

This pull request improves the reliability and setup of the MageForge module in the Magento development environment, especially when the module is bind-mounted rather than installed via Composer. It adds robust checks to ensure the bind-mount is active, automates the installation of third-party dependencies, and clarifies the setup process to prevent common issues related to Docker mounts.

Key changes include:

Bind-mount reliability and verification:

  • Added a guard in .ddev/commands/web/install-magento to check if the MageForge bind-mount is active, providing clear error messages and instructions if the mount is orphaned due to directory deletion while DDEV is running.
  • Updated .ddev/config.yaml to explicitly create the full bind-mount target directory (magento/app/code/OpenForgeProject/MageForge) during pre-start, ensuring correct permissions and preventing mount issues.

Dependency management for bind-mounted modules:

  • Introduced a new script .ddev/commands/web/install-module-deps that reads the module's composer.json and installs any missing non-Magento, non-PHP dependencies into the Magento vendor directory, addressing the limitation that Composer does not resolve dependencies for bind-mounted modules.
  • Updated .ddev/commands/web/install-magento to run the new dependency installation script after copying files and before running setup:upgrade, ensuring all required dependencies are present.
  • Added a post-start hook in .ddev/config.yaml to automatically run the dependency installation script after the environment starts.

Module registration improvements:

  • Modified .ddev/commands/web/install-magento to directly enable the MageForge module in app/etc/config.php via a PHP script, ensuring the module is registered even though it's bind-mounted and not Composer-installed.

Copilot AI review requested due to automatic review settings June 8, 2026 06:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a DDEV-side mechanism to ensure MageForge’s third-party Composer dependencies are installed into the Magento vendor/ directory when MageForge is bind-mounted into app/code (i.e., not Composer-installed in the Magento project).

Changes:

  • Added a new DDEV web command to install missing MageForge composer.json dependencies into the Magento project.
  • Updated the Magento install script to run the dependency installer after installing Hyvä and before enabling the MageForge module.
  • Updated DDEV post-start hook to run the dependency installer automatically on environment start (only when Magento is already installed).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
.ddev/config.yaml Runs the new dependency installer on post-start to keep Magento vendor/ in sync when MageForge is bind-mounted.
.ddev/commands/web/install-module-deps New script that reads MageForge’s composer.json and installs missing non-Magento dependencies into the Magento project.
.ddev/commands/web/install-magento Calls the dependency installer during Magento setup, before enabling MageForge.

Comment thread .ddev/commands/web/install-module-deps Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 8, 2026 08:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread .ddev/commands/web/install-module-deps
Comment thread .ddev/commands/web/install-module-deps Outdated
Comment thread .ddev/commands/web/install-module-deps
@dermatz dermatz changed the title feat!: add script to install MageForge module dependencies and update… feat!: add MageForge bind-mount setup and dependency management Jun 9, 2026
Copilot AI review requested due to automatic review settings June 9, 2026 07:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

.ddev/commands/web/install-magento:34

  • The bind-mount guard runs before the "Magento already installed" short-circuit. This makes ddev install-magento fail on already-installed setups if the mount isn't active, even though the command would otherwise exit early. Consider checking for an existing install first, then validating the bind-mount only when an install is actually needed.
# Guard: verify the MageForge bind-mount is active.
# The Docker bind-mount (../src → .../MageForge) is a kernel-level mount established
# when the containers start. If magento/ was deleted while DDEV was running, the mount
# becomes orphaned: its inode is gone, and recreating the directory produces a new inode
# not covered by the old mount. The module source would then be invisible to Magento.
# The only fix is a container restart, which re-establishes the mount on the new inode.
if [[ ! -f "${MAGENTO_FOLDER}/app/code/OpenForgeProject/MageForge/registration.php" ]]; then
	echo "ERROR: The MageForge bind-mount is not active."
	echo ""
	echo "This happens when magento/ was deleted while DDEV was still running."
	echo ""
	echo "Fix: run 'ddev restart', then re-run 'ddev install-magento'."
	exit 1
fi

# check if Magento is already installed
if [[ -f "${MAGENTO_FOLDER}/bin/magento" ]]; then
	echo "Magento is already installed. Skipping install-magento."
	exit 0
fi

Comment on lines +41 to +48
\$missingConstraints = [];
\$missingNames = [];
foreach (\$deps as \$package => \$constraint) {
if (!is_dir('vendor/' . \$package)) {
\$missingConstraints[] = escapeshellarg(\"\$package:\$constraint\");
\$missingNames[] = escapeshellarg(\$package);
}
}
Comment thread .ddev/commands/web/install-magento Outdated
Comment on lines +109 to +120
php -r "
\$f = 'app/etc/config.php';
\$c = include \$f;
if (empty(\$c['modules']['OpenForgeProject_MageForge'])) {
\$c['modules']['OpenForgeProject_MageForge'] = 1;
ksort(\$c['modules']);
file_put_contents(\$f, '<?php' . PHP_EOL . 'return ' . var_export(\$c, true) . ';' . PHP_EOL);
echo 'Enabled OpenForgeProject_MageForge in app/etc/config.php' . PHP_EOL;
} else {
echo 'OpenForgeProject_MageForge already enabled in app/etc/config.php' . PHP_EOL;
}
"
Copilot AI review requested due to automatic review settings June 9, 2026 08:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment on lines +44 to +56
\$vendorDir = 'vendor/' . \$package;
// Check vendor dir exists AND the installed version satisfies the required constraint.
// A plain directory check would miss constraint changes and leave incompatible versions.
\$installedVersion = null;
\$installedJson = 'vendor/' . \$package . '/composer.json';
if (is_dir(\$vendorDir) && is_file(\$installedJson)) {
\$installed = json_decode(file_get_contents(\$installedJson), true);
\$installedVersion = \$installed['version'] ?? null;
}
\$needsInstall = !is_dir(\$vendorDir);
if (!\$needsInstall && \$installedVersion !== null) {
// Use Composer's own semver check via the lock file if available.
\$lockFile = 'composer.lock';
// This prevents Composer from touching unrelated Magento core dependencies.
passthru('composer require --no-interaction --no-update ' . implode(' ', \$missingConstraints), \$exitCode);
if (\$exitCode !== 0) { exit(\$exitCode); }
passthru('composer update --no-interaction ' . implode(' ', \$missingNames), \$exitCode);
Comment on lines +106 to +110
# Enable MageForge: the module is bind-mounted under app/code/ and therefore not registered
# via Composer autoload. bin/magento module:enable discovers it through the component registrar
# (registration.php), writes the entry to app/etc/config.php, and exits non-zero on any error.
bin/magento module:enable OpenForgeProject_MageForge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants