Skip to content

Commit f34a6c2

Browse files
committed
Install a local copy of COmposer
1 parent d51af36 commit f34a6c2

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

installer.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ async function createProject ( win )
6060
env,
6161
},
6262
);
63+
// Require Composer as a dev dependency so that Package Manager can use it
64+
// without relying on this app.
65+
await execAndStreamOutput(
66+
php,
67+
[ composer, 'require', '--dev', '--no-update', 'composer/composer' ],
68+
{
69+
cwd: projectRoot,
70+
env,
71+
},
72+
);
6373
// Finally, install dependencies. We suppress the progress bar because it
6474
// looks lame when streamed to the renderer.
6575
await execAndStreamOutput(
@@ -89,8 +99,7 @@ async function createProject ( win )
8999
localSettingsFile,
90100
`
91101
$settings['hash_salt'] = '${ randomBytes( 32 ).toString( 'hex' ) }';
92-
$settings['config_sync_directory'] = '${ path.join( projectRoot, 'config' ) }';
93-
$config['package_manager.settings']['executables']['composer'] = '${composer}';`,
102+
$settings['config_sync_directory'] = '${ path.join( projectRoot, 'config' ) }';`
94103
);
95104
// Make sure we load the local settings if using the built-in web server.
96105
await appendFile(

settings.local.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use Composer\InstalledVersions;
4+
35
$databases['default']['default'] = array (
46
'prefix' => '',
57
'database' => 'sites/default/files/.ht.sqlite',
@@ -13,6 +15,18 @@
1315
// Allow use of the direct-write mode added to Package Manager in Drupal 11.2.
1416
$settings['package_manager_allow_direct_write'] = TRUE;
1517

18+
// Use a copy of Composer that is locally installed in the project.
19+
try {
20+
$config['package_manager.settings']['executables']['composer'] = InstalledVersions::getInstallPath('composer/composer') . '/bin/composer';
21+
}
22+
catch (OutOfBoundsException) {
23+
// Can't figure out where Composer is, so don't try to configure it here.
24+
}
25+
26+
// Allow `localhost` as a trusted host pattern to prevent an error on the status
27+
// report.
28+
$settings['trusted_host_patterns'][] = '^localhost$';
29+
1630
// Suppress the warning raised by `skip_permissions_hardening`.
1731
// @see drupal_cms_installer_install_tasks()
1832
putenv('IS_DDEV_PROJECT=1');

0 commit comments

Comments
 (0)