Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Store password in a separate file outside of the ini file. #227

Merged
merged 13 commits into from
Apr 6, 2016
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.idea
/vendor
/dev
composer.lock
Expand Down
11 changes: 11 additions & 0 deletions .phploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
; This is a sample .phploy file. You can specify passwords
; for every server that is in your phploy.ini file.
;
; NOTE: If a value in the .ini file contains any non-alphanumeric
; characters it needs to be enclosed in double-quotes (").

[staging]
password = password

[production]
password = password
Binary file modified bin/phploy.phar
Binary file not shown.
6 changes: 3 additions & 3 deletions phploy.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; This is a sample deploy.ini file. You can specify as many
; This is a sample phploy.ini file. You can specify as many
; servers as you need and use normal or quickmode configuration.
;
; NOTE: If a value in the .ini file contains any non-alphanumeric
Expand All @@ -24,7 +24,7 @@
purge[] = "cache/"
pre-deploy[] = "wget http://staging-example.com/pre-deploy/test.php --spider --quiet"
post-deploy[] = "wget http://staging-example.com/post-deploy/test.php --spider --quiet"

[production]
quickmode = ftp://example:password@production-example.com:21/path/to/installation
passive = true
Expand All @@ -34,6 +34,6 @@
skip[] = 'libs/*'
skip[] = 'config/*'
skip[] = 'src/*.scss'
purge[] = "cache/"
purge[] = "cache/"
pre-deploy[] = "wget http://staging-example.com/pre-deploy/test.php --spider --quiet"
post-deploy[] = "wget http://staging-example.com/post-deploy/test.php --spider --quiet"
11 changes: 11 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ The `phploy.ini` file holds your project configuration. It should be located in
```

If your password is missing in the `phploy.ini` file, PHPloy will interactively ask you for your password.
There is also an option to store the password in a file called `.phploy`.

```
[staging]
password=password

[production]
password=password
```

This feature is especially useful if you would like to share your phploy.ini via Git but hide your password from the public.

## Multiple servers

Expand Down
27 changes: 25 additions & 2 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,25 @@
use League\Flysystem\Filesystem;
use League\Flysystem\Sftp\SftpAdapter as SftpAdapter;

/**
* Class Connection.
*/
class Connection
{
/**
* @var Filesystem
*/
public $server;

/**
* Connection constructor.
*
* @param string $server
*
* @return Connection
*
* @throws \Exception
*/
public function __construct($server)
{
if (!isset($server['scheme'])) {
Expand All @@ -30,7 +45,9 @@ public function __construct($server)
*
* @param string $server
*
* @throws Exception if it can't connect to FTP server
* @return Filesystem|null
*
* @throws \Exception if it can't connect to FTP server
*/
protected function connectToFtp($server)
{
Expand All @@ -47,14 +64,18 @@ protected function connectToFtp($server)
} catch (\Exception $e) {
echo "\r\nOh Snap: {$e->getMessage()}\r\n";
}

return;
}

/**
* Connects to the SFTP Server.
*
* @param string $server
*
* @throws Exception if it can't connect to FTP server
* @return Filesystem|null
*
* @throws \Exception if it can't connect to FTP server
*/
protected function connectToSftp($server)
{
Expand All @@ -71,5 +92,7 @@ protected function connectToSftp($server)
} catch (\Exception $e) {
echo "\r\nOh Snap: {$e->getMessage()}\r\n";
}

return;
}
}
25 changes: 25 additions & 0 deletions src/Git.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Banago\PHPloy;

/**
* Class Git.
*/
class Git
{
/**
Expand All @@ -19,6 +22,11 @@ class Git
*/
protected $repo;

/**
* Git constructor.
*
* @param null $repo
*/
public function __construct($repo = null)
{
$this->repo = $repo;
Expand All @@ -29,6 +37,8 @@ public function __construct($repo = null)
/**
* Executes a console command and returns the output (as an array).
*
* @param string $command Command to execute
*
* @return array of all lines that were output to the console during the command (STDOUT)
*/
public function exec($command)
Expand Down Expand Up @@ -60,6 +70,14 @@ public function command($command, $repoPath = null)
return $this->exec($command);
}

/**
* Diff versions.
*
* @param string $remoteRevision
* @param string $localRevision
*
* @return array
*/
public function diff($remoteRevision, $localRevision)
{
if (empty($remoteRevision)) {
Expand All @@ -74,6 +92,13 @@ public function diff($remoteRevision, $localRevision)
return $this->command($command);
}

/**
* Checkout given $branch.
*
* @param string $branch
*
* @return array
*/
public function checkout($branch)
{
$command = 'checkout '.$branch;
Expand Down
19 changes: 19 additions & 0 deletions src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@

namespace Banago\PHPloy;

use League\CLImate\CLImate;

/**
* Class Options.
*/
class Options
{
/**
* @var CLImate
*/
public $cli;

/**
* Options constructor.
*
* @param CLImate $climate
*/
public function __construct($climate)
{
$this->cli = $climate;
Expand All @@ -14,6 +27,9 @@ public function __construct($climate)
$this->parse();
}

/**
*
*/
protected function build()
{
$this->cli->description('PHPloy - Incremental Git FTP/SFTP deployment tool that supports multiple servers, submodules and rollbacks.');
Expand Down Expand Up @@ -70,6 +86,9 @@ protected function build()
]);
}

/**
*
*/
protected function parse()
{
$this->cli->arguments->parse();
Expand Down
Loading