Closed ttskch closed 8 years ago
workaround:
$ composer create-project wordpress/skeleton {project-name} --no-scripts
$ cd {project-name}
$ ln -s ../../wp-content/themes wp/wp-content/my-themes # or create symlink with some way
$ rm -rf wp/wp-content/plugins
$ ln -s ../../wp-content/plugins wp/wp-content/plugins # or create symlink with some way
@qckanemoto, here is how it can be fixed. Separate set of console commands are used depending on if it is Windows or not. Unfortunately plugins directory removal through PHP causes "Access denied' error on subsequent attempt to create link.
private static function initWordPress()
{
$isWin = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
$projectRoot = dirname(__DIR__);
// create symlinks under wp/wp-content dir.
$paths = array(
array(
'target' => '../../wp-content/themes',
'link' => "{$projectRoot}/wp/wp-content/my-themes",
),
array(
'target' => '../../wp-content/plugins',
'link' => "{$projectRoot}/wp/wp-content/plugins",
),
);
foreach ($paths as $path) {
if ($isWin) {
array_walk($path, function (&$v) {
$v = str_replace('/', '\\', $v);
});
}
if (file_exists($path['link'])) {
$cmd = $isWin ? 'rmdir /s /q %s' : 'rm -rf %s';
exec(sprintf($cmd, escapeshellarg($path['link'])));
}
$cmd = strtr($isWin ? 'mklink /D {link} {target}' : 'ln -s {target} {link}', array(
'{link}' => escapeshellarg($path['link']),
'{target}' => escapeshellarg($path['target']),
));
exec($cmd);
}
}
I've tested it on both Windows 7 and Debian, works fine for me.
@FlyingDR So sorry for my very late reply 🙇 And thanks so much for your advice! I implemented your idea in #7 and merged it 👍
php 5.3+ is ready to use symlink() on windows, but following error occurs on my windows 7 64bit environment... refs. https://bugs.php.net/bug.php?id=48975 ?