Skip to content

Instantly share code, notes, and snippets.

@AlbinoDrought
Last active April 17, 2017 21:12
Show Gist options
  • Save AlbinoDrought/3fb7a41ad840fcd7c508777c651cf2ba to your computer and use it in GitHub Desktop.
Save AlbinoDrought/3fb7a41ad840fcd7c508777c651cf2ba to your computer and use it in GitHub Desktop.
Deploying PHP to a Cygwin Windows machine using Deployer (deployer.org)
function decygwin($path) {
return preg_replace('/\/cygdrive\/(\D)\//', '$1:/', $path);
}
// use native symlinks, because non-native cygwin symlinks are not "directories": `is_dir('cygwin-symlink') == false`
set('env_vars', 'CYGWIN="winsymlinks:nativestrict"');
// cygwin release path fix
// replaces the cygwin release path (/cygdrive/c/) with the windows release path (C:/)
// increases compatibility with things like non-cygwin PHP for composer installs
// fixes "Could not open input file:" PHP errors
set('release_path', function () {
$releaseExists = run("if [ -h {{deploy_path}}/release ]; then echo 'true'; fi")->toBool();
if ($releaseExists) {
$link = run("readlink {{deploy_path}}/release")->toString();
$path = substr($link, 0, 1) === '/' ? $link : get('deploy_path') . '/' . $link;
} else {
$path = get('current_path');
}
return decygwin($path);
});
// symlink fix
// throw our environment variables before the symlink command, so cygwin creates the proper symlinks
set('bin/symlink', function () {
if (get('use_relative_symlink')) {
// Check if target system supports relative symlink.
if (run('if [[ "$(man ln)" =~ "--relative" ]]; then echo "true"; fi')->toBool()) {
$command = 'ln -nfs --relative';
}
}
if(empty($command)) {
$command = 'ln -nfs';
}
return '{{env_vars}} ' . $command;
});
@AlbinoDrought
Copy link
Author

I hope this ends up useful for anyone else who is in this unfortunate situation (deployment to a windows-based machine)

Installed the openssh, git, and curl cygwin packages and setup the openssh server as a service.

If you get this error:

setfacl: unknown option -- R

Add set('writable_mode', 'chown');

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