Skip to content

Commit

Permalink
feature #17 Add option to set remote PHP path (rubenrubiob)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.0.x-dev branch.

Discussion
----------

Add option to set remote PHP path

There are some server configurations/services that have multiple PHP versions installed and, therefore, the default `php` binary may not point to the required version for the project.

I added a new option to that allows to set the remote PHP binary path in deployer configuration:

```php
public function configure()
{
    return $this->getConfigBuilder()
        ->remotePhpBinaryPath('/usr/bin/php7.1')
        // ...
    ;
}
```

Then, all console commands are prepended by the php path:

```
/usr/bin/php7.1-sp /path/to/project/releases/20170528000748/bin/console
```

The default path, in case it is not set, is `php`, as it was set originally.

Commits
-------

c8c4896 Add option to set remote PHP path
  • Loading branch information
javiereguiluz committed May 28, 2017
2 parents 30746d0 + c8c4896 commit 0cd7703
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/Configuration/DefaultConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ final class DefaultConfiguration extends AbstractConfiguration
private $keepReleases = 5;
private $repositoryUrl;
private $repositoryBranch = 'master';
private $remotePhpBinaryPath = 'php';
private $updateRemoteComposerBinary = false;
private $remoteComposerBinaryPath = '/usr/local/bin/composer';
private $composerInstallFlags = '--no-dev --prefer-dist --no-interaction --quiet';
Expand Down Expand Up @@ -123,6 +124,13 @@ public function repositoryBranch(string $branchName) : self
return $this;
}

public function remotePhpBinaryPath(string $path) : self
{
$this->remotePhpBinaryPath = $path;

return $this;
}

public function updateRemoteComposerBinary(bool $updateBeforeInstall) : self
{
$this->updateRemoteComposerBinary = $updateBeforeInstall;
Expand Down
1 change: 1 addition & 0 deletions src/Configuration/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ final class Option
const permissionMode = 'permissionMode';
const permissionUser = 'permissionUser';
const permissionGroup = 'permissionGroup';
const remotePhpBinaryPath = 'remotePhpBinaryPath';
const remoteComposerBinaryPath = 'remoteComposerBinaryPath';
const repositoryBranch = 'repositoryBranch';
const repositoryUrl = 'repositoryUrl';
Expand Down
2 changes: 1 addition & 1 deletion src/Deployer/DefaultDeployer.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private function initializeDirectoryLayout(Server $server) : void
$server->set(Property::web_dir, sprintf('%s/%s', $remoteProjectDir, $this->getConfig(Option::webDir)));

// this is needed because some projects use a binary directory different than the default one of their Symfony version
$server->set(Property::console_bin, sprintf('php %s/console', $this->getConfig(Option::binDir) ? $server->get(Property::bin_dir) : $this->findConsoleBinaryPath($server)));
$server->set(Property::console_bin, sprintf('%s %s/console', $this->getConfig(Option::remotePhpBinaryPath), $this->getConfig(Option::binDir) ? $server->get(Property::bin_dir) : $this->findConsoleBinaryPath($server)));
}

// this is needed because it's common for Smyfony projects to use binary directories
Expand Down

0 comments on commit 0cd7703

Please sign in to comment.