Skip to content

Commit

Permalink
moved to namespace Deployment (BC break)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Sep 2, 2014
1 parent 6e1a0b0 commit 7567b74
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Deployment/deployment.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Deployment;

require __DIR__ . '/libs/Server.php';
require __DIR__ . '/libs/FtpServer.php';
require __DIR__ . '/libs/SshServer.php';
Expand Down
3 changes: 2 additions & 1 deletion Deployment/libs/CliRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Copyright (c) 2009 David Grudl (http://davidgrudl.com)
*/

namespace Deployment;


/**
Expand Down Expand Up @@ -98,7 +99,7 @@ private function createDeployer($config)
];

if (empty($config['remote']) || !parse_url($config['remote'])) {
throw new Exception("Missing or invalid 'remote' URL in config.");
throw new \Exception("Missing or invalid 'remote' URL in config.");
}

$server = parse_url($config['remote'], PHP_URL_SCHEME) === 'sftp'
Expand Down
1 change: 1 addition & 0 deletions Deployment/libs/CommandLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Copyright (c) 2009 David Grudl (http://davidgrudl.com)
*/

namespace Deployment;


/**
Expand Down
9 changes: 5 additions & 4 deletions Deployment/libs/Deployer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Copyright (c) 2009 David Grudl (http://davidgrudl.com)
*/

namespace Deployment;


/**
Expand Down Expand Up @@ -66,7 +67,7 @@ public function __construct(Server $server, $local, Logger $logger)
{
$this->local = realpath($local);
if (!$this->local) {
throw new InvalidArgumentException("Directory $local not found.");
throw new \InvalidArgumentException("Directory $local not found.");
}
$this->server = $server;
$this->logger = $logger;
Expand Down Expand Up @@ -374,16 +375,16 @@ private function runJobs(array $jobs)
}
$this->logger->log("$job: $out");
if ($err) {
throw new RuntimeException("Error in job $job");
throw new \RuntimeException("Error in job $job");
}

} elseif (is_callable($job)) {
if ($job($this->server, $this->logger, $this) === FALSE) {
throw new RuntimeException('Error in job');
throw new \RuntimeException('Error in job');
}

} else {
throw new InvalidArgumentException("Invalid job $job.");
throw new \InvalidArgumentException("Invalid job $job.");
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions Deployment/libs/FtpServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Copyright (c) 2009 David Grudl (http://davidgrudl.com)
*/

namespace Deployment;


/**
Expand Down Expand Up @@ -35,11 +36,11 @@ class FtpServer implements Server
public function __construct($url, $passiveMode = TRUE)
{
if (!extension_loaded('ftp')) {
throw new Exception('PHP extension FTP is not loaded.');
throw new \Exception('PHP extension FTP is not loaded.');
}
$parts = parse_url($url);
if (!isset($parts['scheme'], $parts['user'], $parts['pass']) || ($parts['scheme'] !== 'ftp' && $parts['scheme'] !== 'ftps')) {
throw new InvalidArgumentException("Invalid URL or missing username or password: $url");
throw new \InvalidArgumentException("Invalid URL or missing username or password: $url");
}
$this->url = $url;
$this->passiveMode = (bool) $passiveMode;
Expand Down
1 change: 1 addition & 0 deletions Deployment/libs/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Copyright (c) 2009 David Grudl (http://davidgrudl.com)
*/

namespace Deployment;


/**
Expand Down
3 changes: 2 additions & 1 deletion Deployment/libs/Preprocessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Copyright (c) 2009 David Grudl (http://davidgrudl.com)
*/

namespace Deployment;


/**
Expand Down Expand Up @@ -121,7 +122,7 @@ private function execute($command, $input)
NULL, NULL, ['bypass_shell' => TRUE]
);
if (!is_resource($process)) {
throw new Exception("Unable start process $command.");
throw new \Exception("Unable start process $command.");
}

fwrite($pipes[0], $input);
Expand Down
3 changes: 2 additions & 1 deletion Deployment/libs/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Copyright (c) 2009 David Grudl (http://davidgrudl.com)
*/

namespace Deployment;


/**
Expand Down Expand Up @@ -81,6 +82,6 @@ function execute($command);



class ServerException extends Exception
class ServerException extends \Exception
{
}
5 changes: 3 additions & 2 deletions Deployment/libs/SshServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Copyright (c) 2009 David Grudl (http://davidgrudl.com)
*/

namespace Deployment;


/**
Expand All @@ -32,11 +33,11 @@ class SshServer implements Server
public function __construct($url)
{
if (!extension_loaded('ssh2')) {
throw new Exception('PHP extension SSH2 is not loaded.');
throw new \Exception('PHP extension SSH2 is not loaded.');
}
$parts = parse_url($url);
if (!isset($parts['scheme'], $parts['user']) || $parts['scheme'] !== 'sftp') {
throw new InvalidArgumentException("Invalid URL or missing username: $url");
throw new \InvalidArgumentException("Invalid URL or missing username: $url");
}
$this->url = $url;
}
Expand Down
2 changes: 1 addition & 1 deletion deployment.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
',
'allowdelete' => TRUE,
'before' => array(
function (Server $server, Logger $logger, Deployer $deployer) {
function (Deployment\Server $server, Deployment\Logger $logger, Deployment\Deployer $deployer) {
$logger->log('Hello!');
},
),
Expand Down

0 comments on commit 7567b74

Please sign in to comment.