From bcfc5578de5a3993bc5ebe1891cee9600c792f90 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Wed, 1 Feb 2017 19:52:35 +0700 Subject: [PATCH 01/13] Moved commands to Application from console.php --- bin/console | 23 +--------- src/PHPCensor/Command/CreateBuildCommand.php | 1 + src/PHPCensor/Console/Application.php | 44 ++++++++++++++++++-- 3 files changed, 43 insertions(+), 25 deletions(-) diff --git a/bin/console b/bin/console index bfaf4dae..4efa0a54 100755 --- a/bin/console +++ b/bin/console @@ -9,16 +9,6 @@ * @link http://www.phptesting.org/ */ -use PHPCensor\Command\RunCommand; -use PHPCensor\Command\RebuildCommand; -use PHPCensor\Command\InstallCommand; -use PHPCensor\Command\PollCommand; -use PHPCensor\Command\CreateAdminCommand; -use PHPCensor\Command\CreateBuildCommand; -use PHPCensor\Command\WorkerCommand; -use PHPCensor\Command\RebuildQueueCommand; -use PHPCensor\Service\BuildService; -use b8\Store\Factory; use PHPCensor\Console\Application; define('IS_CONSOLE', true); @@ -28,15 +18,4 @@ ini_set('display_errors', 1); require_once(dirname(__DIR__) . '/bootstrap.php'); -$application = new Application(); - -$application->add(new RunCommand($loggerConfig->getFor('RunCommand'))); -$application->add(new RebuildCommand($loggerConfig->getFor('RunCommand'))); -$application->add(new InstallCommand); -$application->add(new PollCommand($loggerConfig->getFor('PollCommand'))); -$application->add(new CreateAdminCommand(Factory::getStore('User'))); -$application->add(new CreateBuildCommand(Factory::getStore('Project'), new BuildService(Factory::getStore('Build')))); -$application->add(new WorkerCommand($loggerConfig->getFor('WorkerCommand'))); -$application->add(new RebuildQueueCommand($loggerConfig->getFor('RebuildQueueCommand'))); - -$application->run(); +(new Application())->run(); diff --git a/src/PHPCensor/Command/CreateBuildCommand.php b/src/PHPCensor/Command/CreateBuildCommand.php index 7df3f7b2..a49d30c0 100644 --- a/src/PHPCensor/Command/CreateBuildCommand.php +++ b/src/PHPCensor/Command/CreateBuildCommand.php @@ -39,6 +39,7 @@ class CreateBuildCommand extends Command /** * @param ProjectStore $projectStore + * @param BuildService $buildService */ public function __construct(ProjectStore $projectStore, BuildService $buildService) { diff --git a/src/PHPCensor/Console/Application.php b/src/PHPCensor/Console/Application.php index 9923e16f..70fd52c7 100644 --- a/src/PHPCensor/Console/Application.php +++ b/src/PHPCensor/Console/Application.php @@ -3,6 +3,20 @@ namespace PHPCensor\Console; use b8\Config; +use b8\Store\Factory; +use PHPCensor\Command\CreateAdminCommand; +use PHPCensor\Command\CreateBuildCommand; +use PHPCensor\Command\InstallCommand; +use PHPCensor\Command\PollCommand; +use PHPCensor\Command\RebuildCommand; +use PHPCensor\Command\RebuildQueueCommand; +use PHPCensor\Command\RunCommand; +use PHPCensor\Command\WorkerCommand; +use PHPCensor\Logging\LoggerConfig; +use PHPCensor\Service\BuildService; +use PHPCensor\Store\BuildStore; +use PHPCensor\Store\ProjectStore; +use PHPCensor\Store\UserStore; use Symfony\Component\Console\Application as BaseApplication; use Phinx\Console\Command\Create; use Phinx\Console\Command\Migrate; @@ -10,15 +24,21 @@ use Phinx\Console\Command\Rollback; use Phinx\Console\Command\Status; use Phinx\Config\Config as PhinxConfig; +/** + * Class Application + * + * @package PHPCensor\Console + */ class Application extends BaseApplication { /** * Constructor. * - * @param string $name The name of the application - * @param string $version The version of the application + * @param string $name The name of the application + * @param string $version The version of the application + * @param LoggerConfig $loggerConfig Logger config */ - public function __construct($name = 'PHP Censor - Continuous Integration for PHP', $version = '') + public function __construct($name = 'PHP Censor - Continuous Integration for PHP', $version = '', LoggerConfig $loggerConfig = null) { parent::__construct($name, $version); @@ -68,5 +88,23 @@ class Application extends BaseApplication ->setConfig($phinxConfig) ->setName('php-censor-migrations:status') ); + + /** @var UserStore $userStore */ + $userStore = Factory::getStore('User'); + + /** @var ProjectStore $projectStore */ + $projectStore = Factory::getStore('Project'); + + /** @var BuildStore $buildStore */ + $buildStore = Factory::getStore('Build'); + + $this->add(new RunCommand($loggerConfig->getFor('RunCommand'))); + $this->add(new RebuildCommand($loggerConfig->getFor('RunCommand'))); + $this->add(new InstallCommand()); + $this->add(new PollCommand($loggerConfig->getFor('PollCommand'))); + $this->add(new CreateAdminCommand($userStore)); + $this->add(new CreateBuildCommand($projectStore, new BuildService($buildStore))); + $this->add(new WorkerCommand($loggerConfig->getFor('WorkerCommand'))); + $this->add(new RebuildQueueCommand($loggerConfig->getFor('RebuildQueueCommand'))); } } From c1d8beb5f0d6f84d642a4c67eef9353d7c4d8c3e Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Wed, 1 Feb 2017 20:07:05 +0700 Subject: [PATCH 02/13] Removed constant IS_CONSOLE --- bin/console | 2 -- bootstrap.php | 10 ---------- tests/bootstrap.php | 8 -------- 3 files changed, 20 deletions(-) diff --git a/bin/console b/bin/console index 4efa0a54..438ad5b9 100755 --- a/bin/console +++ b/bin/console @@ -11,8 +11,6 @@ use PHPCensor\Console\Application; -define('IS_CONSOLE', true); - error_reporting(-1); ini_set('display_errors', 1); diff --git a/bootstrap.php b/bootstrap.php index 1c238a1a..d1af2f40 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -7,8 +7,6 @@ * @link http://www.phptesting.org/ */ -use PHPCensor\Logging\LoggerConfig; - if (!defined('ROOT_DIR')) { define('ROOT_DIR', __DIR__ . DIRECTORY_SEPARATOR); } @@ -39,10 +37,6 @@ if (!defined('IS_WIN')) { require_once(ROOT_DIR . 'vendor/autoload.php'); -if (defined('IS_CONSOLE') && IS_CONSOLE) { - $loggerConfig = LoggerConfig::newFromFile(APP_DIR . "loggerconfig.php"); -} - // Load configuration if present: $conf = []; $conf['b8']['app']['namespace'] = 'PHPCensor'; @@ -60,8 +54,4 @@ if (!defined('APP_URL') && !empty($config)) { define('APP_URL', $config->get('php-censor.url', '') . '/'); } -if (!defined('IS_CONSOLE')) { - define('IS_CONSOLE', false); -} - \PHPCensor\Helper\Lang::init($config); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index adf83769..b36266f6 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -39,10 +39,6 @@ if (!defined('IS_WIN')) { require_once(ROOT_DIR . 'vendor/autoload.php'); -if (defined('IS_CONSOLE') && IS_CONSOLE) { - $loggerConfig = LoggerConfig::newFromFile(APP_DIR . "loggerconfig.php"); -} - // Load configuration if present: $conf = []; $conf['b8']['app']['namespace'] = 'PHPCensor'; @@ -60,8 +56,4 @@ if (!defined('APP_URL') && !empty($config)) { define('APP_URL', $config->get('php-censor.url', '') . '/'); } -if (!defined('IS_CONSOLE')) { - define('IS_CONSOLE', false); -} - \PHPCensor\Helper\Lang::init($config, 'en'); From 7e735bbb3b5484346fa0c6970ff9db084df13cbd Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Wed, 1 Feb 2017 21:53:31 +0700 Subject: [PATCH 03/13] Queue improvements --- app/config.example.yml | 7 +-- src/PHPCensor/Builder.php | 4 +- src/PHPCensor/Command/InstallCommand.php | 46 +++++++++++-------- src/PHPCensor/Command/PollCommand.php | 2 +- src/PHPCensor/Command/RebuildCommand.php | 1 + src/PHPCensor/Command/RunCommand.php | 14 ++++-- src/PHPCensor/Controller/BuildController.php | 2 +- src/PHPCensor/Model/Build.php | 2 +- src/PHPCensor/Service/BuildStatusService.php | 2 +- src/PHPCensor/Store/Base/BuildStoreBase.php | 8 +++- src/PHPCensor/View/Build/header-row.phtml | 2 +- src/PHPCensor/View/Home/ajax-timeline.phtml | 2 +- src/PHPCensor/View/Home/index.phtml | 2 +- src/PHPCensor/Worker/BuildWorker.php | 4 +- .../PHPCensor/Command/InstallCommandTest.php | 2 +- tests/PHPCensor/Model/BuildTest.php | 2 +- tests/PHPCensor/Service/BuildServiceTest.php | 4 +- .../Service/BuiltStatusServiceTest.php | 2 +- 18 files changed, 65 insertions(+), 43 deletions(-) diff --git a/app/config.example.yml b/app/config.example.yml index 48e920eb..eeb36973 100644 --- a/app/config.example.yml +++ b/app/config.example.yml @@ -19,9 +19,10 @@ php-censor: from_address: 'no-reply@php-censor.local' smtp_address: queue: - host: localhost - name: php-censor-queue - lifetime: 600 + use_queue: true + host: localhost + name: php-censor-queue + lifetime: 600 github: token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' comments: diff --git a/src/PHPCensor/Builder.php b/src/PHPCensor/Builder.php index 614c19fb..2eda61ac 100644 --- a/src/PHPCensor/Builder.php +++ b/src/PHPCensor/Builder.php @@ -190,7 +190,7 @@ class Builder implements LoggerAwareInterface $previous_build = $this->build->getProject()->getPreviousBuild($this->build->getBranch()); - $previous_state = Build::STATUS_NEW; + $previous_state = Build::STATUS_PENDING; if ($previous_build) { $previous_state = $previous_build->getStatus(); @@ -223,7 +223,7 @@ class Builder implements LoggerAwareInterface } else { $this->pluginExecutor->executePlugins($this->config, 'failure'); - if ($previous_state == Build::STATUS_SUCCESS || $previous_state == Build::STATUS_NEW) { + if ($previous_state == Build::STATUS_SUCCESS || $previous_state == Build::STATUS_PENDING) { $this->pluginExecutor->executePlugins($this->config, 'broken'); } } diff --git a/src/PHPCensor/Command/InstallCommand.php b/src/PHPCensor/Command/InstallCommand.php index eca0e9d9..d3a7c4bc 100644 --- a/src/PHPCensor/Command/InstallCommand.php +++ b/src/PHPCensor/Command/InstallCommand.php @@ -43,6 +43,7 @@ class InstallCommand extends Command $this ->setName('php-censor:install') + ->addOption('url', null, InputOption::VALUE_OPTIONAL, Lang::get('installation_url')) ->addOption('db-type', null, InputOption::VALUE_OPTIONAL, Lang::get('db_host')) ->addOption('db-host', null, InputOption::VALUE_OPTIONAL, Lang::get('db_host')) @@ -54,9 +55,10 @@ class InstallCommand extends Command ->addOption('admin-pass', null, InputOption::VALUE_OPTIONAL, Lang::get('admin_pass')) ->addOption('admin-mail', null, InputOption::VALUE_OPTIONAL, Lang::get('admin_email')) ->addOption('config-path', null, InputOption::VALUE_OPTIONAL, Lang::get('config_path'), $defaultPath) - ->addOption('queue-disabled', null, InputOption::VALUE_NONE, 'Don\'t ask for queue details') - ->addOption('queue-server', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue server hostname') + ->addOption('queue-use', null, InputOption::VALUE_OPTIONAL, 'Don\'t ask for queue details') + ->addOption('queue-host', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue server hostname') ->addOption('queue-name', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue name') + ->setDescription(Lang::get('install_app')); } @@ -250,45 +252,53 @@ class InstallCommand extends Command $config['per_page'] = 10; $config['url'] = $url; - $config['queue'] = $this->getQueueInformation($input, $output, $helper); + $config['queue'] = $this->getQueueInformation($input, $output); return $config; } /** * If the user wants to use a queue, get the necessary details. + * * @param InputInterface $input * @param OutputInterface $output - * @param QuestionHelper $helper * @return array */ - protected function getQueueInformation(InputInterface $input, OutputInterface $output, QuestionHelper $helper) + protected function getQueueInformation(InputInterface $input, OutputInterface $output) { - if ($input->getOption('queue-disabled')) { - return null; + $skipQueueConfig = [ + 'queue-use' => false, + ]; + + if (!$input->getOption('queue-use')) { + return $skipQueueConfig; } - $rtn = []; + $queueConfig = [ + 'queue-use' => true, + ]; - $helper = $this->getHelper('question'); - $question = new ConfirmationQuestion('Use beanstalkd to manage build queue? ', true); + /** @var $helper QuestionHelper */ + $helper = $this->getHelper('question'); + $question = new ConfirmationQuestion('Use beanstalkd to manage build queue? ', false); if (!$helper->ask($input, $output, $question)) { $output->writeln('Skipping beanstalkd configuration.'); - return null; + + return $skipQueueConfig; } - if (!$rtn['host'] = $input->getOption('queue-server')) { - $questionQueue = new Question('Enter your beanstalkd hostname [localhost]: ', 'localhost'); - $rtn['host'] = $helper->ask($input, $output, $questionQueue); + if (!$queueConfig['host'] = $input->getOption('queue-host')) { + $questionQueue = new Question('Enter your beanstalkd hostname [localhost]: ', 'localhost'); + $queueConfig['host'] = $helper->ask($input, $output, $questionQueue); } - if (!$rtn['name'] = $input->getOption('queue-name')) { - $questionName = new Question('Enter the queue (tube) name to use [php-censor-queue]: ', 'php-censor-queue'); - $rtn['name'] = $helper->ask($input, $output, $questionName); + if (!$queueConfig['name'] = $input->getOption('queue-name')) { + $questionName = new Question('Enter the queue (tube) name to use [php-censor-queue]: ', 'php-censor-queue'); + $queueConfig['name'] = $helper->ask($input, $output, $questionName); } - return $rtn; + return $queueConfig; } /** diff --git a/src/PHPCensor/Command/PollCommand.php b/src/PHPCensor/Command/PollCommand.php index 32ac9a04..8c43a637 100644 --- a/src/PHPCensor/Command/PollCommand.php +++ b/src/PHPCensor/Command/PollCommand.php @@ -87,7 +87,7 @@ class PollCommand extends Command $build = new Build(); $build->setProjectId($project->getId()); $build->setCommitId($last_commit); - $build->setStatus(Build::STATUS_NEW); + $build->setStatus(Build::STATUS_PENDING); $build->setBranch($project->getBranch()); $build->setCreated(new \DateTime()); $build->setCommitMessage($message); diff --git a/src/PHPCensor/Command/RebuildCommand.php b/src/PHPCensor/Command/RebuildCommand.php index 31b10827..f3e06174 100644 --- a/src/PHPCensor/Command/RebuildCommand.php +++ b/src/PHPCensor/Command/RebuildCommand.php @@ -1,4 +1,5 @@ hasOption('debug') && $input->getOption('debug')) { $output->writeln('Debug mode enabled.'); define('DEBUG_MODE', true); @@ -90,8 +91,11 @@ class RunCommand extends Command $this->logger->pushProcessor(new LoggedBuildContextTidier()); $this->logger->addInfo(Lang::get('finding_builds')); - $store = Factory::getStore('Build'); - $result = $store->getByStatus(0, $this->maxBuilds); + + /** @var BuildStore $store */ + $store = Factory::getStore('Build'); + $result = $store->getByStatus(Build::STATUS_PENDING, $this->maxBuilds); + $this->logger->addInfo(Lang::get('found_n_builds', count($result['items']))); $builds = 0; @@ -147,7 +151,7 @@ class RunCommand extends Command { /** @var \PHPCensor\Store\BuildStore $store */ $store = Factory::getStore('Build'); - $running = $store->getByStatus(1); + $running = $store->getByStatus(Build::STATUS_RUNNING); $rtn = []; $timeout = Config::getInstance()->get('php-censor.build.failed_after', 1800); diff --git a/src/PHPCensor/Controller/BuildController.php b/src/PHPCensor/Controller/BuildController.php index 5f71f718..7a0ed2f0 100644 --- a/src/PHPCensor/Controller/BuildController.php +++ b/src/PHPCensor/Controller/BuildController.php @@ -272,7 +272,7 @@ class BuildController extends Controller public function ajaxQueue() { $rtn = [ - 'pending' => $this->formatBuilds($this->buildStore->getByStatus(Build::STATUS_NEW)), + 'pending' => $this->formatBuilds($this->buildStore->getByStatus(Build::STATUS_PENDING)), 'running' => $this->formatBuilds($this->buildStore->getByStatus(Build::STATUS_RUNNING)), ]; diff --git a/src/PHPCensor/Model/Build.php b/src/PHPCensor/Model/Build.php index fc553d59..4e7d420c 100644 --- a/src/PHPCensor/Model/Build.php +++ b/src/PHPCensor/Model/Build.php @@ -21,7 +21,7 @@ use Symfony\Component\Yaml\Parser as YamlParser; */ class Build extends BuildBase { - const STATUS_NEW = 0; + const STATUS_PENDING = 0; const STATUS_RUNNING = 1; const STATUS_SUCCESS = 2; const STATUS_FAILED = 3; diff --git a/src/PHPCensor/Service/BuildStatusService.php b/src/PHPCensor/Service/BuildStatusService.php index 0f29415d..dcde6ee6 100644 --- a/src/PHPCensor/Service/BuildStatusService.php +++ b/src/PHPCensor/Service/BuildStatusService.php @@ -105,7 +105,7 @@ class BuildStatusService { if (in_array($this->build->getStatus(), $this->finishedStatusIds)) { return 'Sleeping'; - } elseif ($this->build->getStatus() == Build::STATUS_NEW) { + } elseif ($this->build->getStatus() == Build::STATUS_PENDING) { return 'Pending'; } elseif ($this->build->getStatus() == Build::STATUS_RUNNING) { return 'Building'; diff --git a/src/PHPCensor/Store/Base/BuildStoreBase.php b/src/PHPCensor/Store/Base/BuildStoreBase.php index 442c79eb..849c1a65 100644 --- a/src/PHPCensor/Store/Base/BuildStoreBase.php +++ b/src/PHPCensor/Store/Base/BuildStoreBase.php @@ -85,7 +85,14 @@ class BuildStoreBase extends Store /** * Get multiple Build by Status. + * + * @param $value + * @param int $limit + * @param string $useConnection + * * @return array + * + * @throws HttpException */ public function getByStatus($value, $limit = 1000, $useConnection = 'read') { @@ -93,7 +100,6 @@ class BuildStoreBase extends Store throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.'); } - $query = 'SELECT * FROM {{build}} WHERE {{status}} = :status LIMIT :limit'; $stmt = Database::getConnection($useConnection)->prepareCommon($query); $stmt->bindValue(':status', $value); diff --git a/src/PHPCensor/View/Build/header-row.phtml b/src/PHPCensor/View/Build/header-row.phtml index 417c1c72..7bb8f4d0 100644 --- a/src/PHPCensor/View/Build/header-row.phtml +++ b/src/PHPCensor/View/Build/header-row.phtml @@ -10,7 +10,7 @@

getProject()->getTitle(); ?> - getStatus() == \PHPCensor\Model\Build::STATUS_NEW): ?> + getStatus() == \PHPCensor\Model\Build::STATUS_PENDING): ?> getCreated()->format('H:i')); ?> getStatus() == \PHPCensor\Model\Build::STATUS_RUNNING): ?> getStarted()->format('H:i')); ?> diff --git a/src/PHPCensor/View/Home/ajax-timeline.phtml b/src/PHPCensor/View/Home/ajax-timeline.phtml index 4d6f9a03..55fa651e 100644 --- a/src/PHPCensor/View/Home/ajax-timeline.phtml +++ b/src/PHPCensor/View/Home/ajax-timeline.phtml @@ -5,7 +5,7 @@ getStatus()) { - case \PHPCensor\Model\Build::STATUS_NEW: + case \PHPCensor\Model\Build::STATUS_PENDING: $updated = $build->getCreated(); $label = Lang::get('pending'); $color = 'blue'; diff --git a/src/PHPCensor/View/Home/index.phtml b/src/PHPCensor/View/Home/index.phtml index fe5ad109..6562c463 100644 --- a/src/PHPCensor/View/Home/index.phtml +++ b/src/PHPCensor/View/Home/index.phtml @@ -31,7 +31,7 @@ getStatus()) { - case \PHPCensor\Model\Build::STATUS_NEW: + case \PHPCensor\Model\Build::STATUS_PENDING: $updated = $build->getCreated(); $label = Lang::get('pending'); $color = 'blue'; diff --git a/src/PHPCensor/Worker/BuildWorker.php b/src/PHPCensor/Worker/BuildWorker.php index 2302b3b2..10066d0e 100644 --- a/src/PHPCensor/Worker/BuildWorker.php +++ b/src/PHPCensor/Worker/BuildWorker.php @@ -59,8 +59,8 @@ class BuildWorker */ public function __construct($host, $queue) { - $this->host = $host; - $this->queue = $queue; + $this->host = $host; + $this->queue = $queue; $this->pheanstalk = new Pheanstalk($this->host); } diff --git a/tests/PHPCensor/Command/InstallCommandTest.php b/tests/PHPCensor/Command/InstallCommandTest.php index 5c8e2404..fa56408a 100644 --- a/tests/PHPCensor/Command/InstallCommandTest.php +++ b/tests/PHPCensor/Command/InstallCommandTest.php @@ -107,7 +107,7 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase '--admin-name' => 'admin', '--admin-pass' => 'admin-password', '--url' => 'http://php-censor.local', - '--queue-disabled' => null, + '--queue-use' => null, ]; if (!is_null($exclude)) { diff --git a/tests/PHPCensor/Model/BuildTest.php b/tests/PHPCensor/Model/BuildTest.php index 3fac5c90..f7858e02 100644 --- a/tests/PHPCensor/Model/BuildTest.php +++ b/tests/PHPCensor/Model/BuildTest.php @@ -43,7 +43,7 @@ class BuildTest extends \PHPUnit_Framework_TestCase public function testExecute_TestIsSuccessful() { $build = new Build(); - $build->setStatus(Build::STATUS_NEW); + $build->setStatus(Build::STATUS_PENDING); $this->assertFalse($build->isSuccessful()); $build->setStatus(Build::STATUS_RUNNING); diff --git a/tests/PHPCensor/Service/BuildServiceTest.php b/tests/PHPCensor/Service/BuildServiceTest.php index 46f721c4..65df07d7 100644 --- a/tests/PHPCensor/Service/BuildServiceTest.php +++ b/tests/PHPCensor/Service/BuildServiceTest.php @@ -50,7 +50,7 @@ class BuildServiceTest extends \PHPUnit_Framework_TestCase $returnValue = $this->testedService->createBuild($project); $this->assertEquals(101, $returnValue->getProjectId()); - $this->assertEquals(Build::STATUS_NEW, $returnValue->getStatus()); + $this->assertEquals(Build::STATUS_PENDING, $returnValue->getStatus()); $this->assertNull($returnValue->getStarted()); $this->assertNull($returnValue->getFinished()); $this->assertNull($returnValue->getLog()); @@ -108,7 +108,7 @@ class BuildServiceTest extends \PHPUnit_Framework_TestCase $this->assertEquals($build->getProjectId(), $returnValue->getProjectId()); $this->assertEquals($build->getCommitId(), $returnValue->getCommitId()); $this->assertNotEquals($build->getStatus(), $returnValue->getStatus()); - $this->assertEquals(Build::STATUS_NEW, $returnValue->getStatus()); + $this->assertEquals(Build::STATUS_PENDING, $returnValue->getStatus()); $this->assertNull($returnValue->getLog()); $this->assertEquals($build->getBranch(), $returnValue->getBranch()); $this->assertNotEquals($build->getCreated(), $returnValue->getCreated()); diff --git a/tests/PHPCensor/Service/BuiltStatusServiceTest.php b/tests/PHPCensor/Service/BuiltStatusServiceTest.php index 7a31c6f1..a50a74c6 100644 --- a/tests/PHPCensor/Service/BuiltStatusServiceTest.php +++ b/tests/PHPCensor/Service/BuiltStatusServiceTest.php @@ -80,7 +80,7 @@ class BuildStatusServiceTest extends \PHPUnit_Framework_TestCase 'previousBuild' => null, ], '5' => [ - 'status' => Build::STATUS_NEW, + 'status' => Build::STATUS_PENDING, 'id' => 1000, 'finishDateTime' => '2014-12-25 21:12:21', 'previousBuild' => 3, From 8779880a8f512975af06d668baee3d389c035c46 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Wed, 1 Feb 2017 22:27:47 +0700 Subject: [PATCH 04/13] Removed hacks for Windows OS (Because it isn't work fine all the same) --- README.md | 16 +++++- bootstrap.php | 4 -- src/PHPCensor/Builder.php | 6 +- src/PHPCensor/Helper/SshKey.php | 11 +--- .../Helper/WindowsCommandExecutor.php | 30 ---------- src/PHPCensor/Model/Build.php | 4 +- src/PHPCensor/Model/Build/LocalBuild.php | 3 - src/PHPCensor/Model/Build/RemoteGitBuild.php | 21 ++----- src/PHPCensor/Model/Build/SubversionBuild.php | 16 ++---- src/PHPCensor/Plugin/CleanBuild.php | 4 +- src/PHPCensor/Plugin/Codeception.php | 4 -- src/PHPCensor/Plugin/Composer.php | 9 +-- src/PHPCensor/Plugin/CopyBuild.php | 6 -- src/PHPCensor/Plugin/Grunt.php | 6 -- src/PHPCensor/Plugin/Gulp.php | 6 -- src/PHPCensor/Plugin/Wipe.php | 5 +- src/PHPCensor/ProcessControl/Factory.php | 8 +-- .../ProcessControl/WindowsProcessControl.php | 56 ------------------- .../PHPCensor/Helper/CommandExecutorTest.php | 8 +-- .../WindowsProcessControlTest.php | 22 -------- .../Security/Authentication/ServiceTest.php | 15 ----- .../UserProvider/InternalTest.php | 12 ---- tests/bootstrap.php | 4 -- 23 files changed, 36 insertions(+), 240 deletions(-) delete mode 100644 src/PHPCensor/Helper/WindowsCommandExecutor.php delete mode 100644 src/PHPCensor/ProcessControl/WindowsProcessControl.php delete mode 100644 tests/PHPCensor/ProcessControl/WindowsProcessControlTest.php diff --git a/README.md b/README.md index 700f5915..7f6c7415 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,19 @@ PHP Censor More [screenshots](docs/en/screenshots.md). +System requirements +------------------- + +* Unix-like OS (**Windows isn't supported**) + +* PHP 5.6+ (with OpenSSL support and enabled functions: `exec()`, `shell_exec()` and `proc_open()`) + +* Web-server (Nginx or Apache2) + +* Database (MySQL/MariaDB or PostgreSQL) + +* Beanstalkd queue (Optional) + Features -------- @@ -72,9 +85,6 @@ More details about [configuring project](docs/en/config.md). Installing ---------- -You will need PHP 5.6+ (with OpenSSL support and enabled functions: `exec()`, `shell_exec()` and `proc_open()`) -with web-server (Nginx or Apache2), DB (MySQL/MariaDB or PostgreSQL) database and Composer. - * Go to the directory in which you want to install PHP Censor, for example: `/var/www`; * Download PHP Censor from this repository and unzip it (to `/var/www/php-censor.local` for example); diff --git a/bootstrap.php b/bootstrap.php index d1af2f40..13222634 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -31,10 +31,6 @@ if (!defined('RUNTIME_DIR')) { define('RUNTIME_DIR', ROOT_DIR . 'runtime' . DIRECTORY_SEPARATOR); } -if (!defined('IS_WIN')) { - define('IS_WIN', ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false)); -} - require_once(ROOT_DIR . 'vendor/autoload.php'); // Load configuration if present: diff --git a/src/PHPCensor/Builder.php b/src/PHPCensor/Builder.php index 2eda61ac..868b138e 100644 --- a/src/PHPCensor/Builder.php +++ b/src/PHPCensor/Builder.php @@ -113,11 +113,7 @@ class Builder implements LoggerAwareInterface $pluginFactory = $this->buildPluginFactory($build); $this->pluginExecutor = new Plugin\Util\Executor($pluginFactory, $this->buildLogger); - $executorClass = 'PHPCensor\Helper\UnixCommandExecutor'; - if (IS_WIN) { - $executorClass = 'PHPCensor\Helper\WindowsCommandExecutor'; - } - + $executorClass = 'PHPCensor\Helper\UnixCommandExecutor'; $this->commandExecutor = new $executorClass( $this->buildLogger, ROOT_DIR, diff --git a/src/PHPCensor/Helper/SshKey.php b/src/PHPCensor/Helper/SshKey.php index 3379148d..a8c946e7 100644 --- a/src/PHPCensor/Helper/SshKey.php +++ b/src/PHPCensor/Helper/SshKey.php @@ -22,16 +22,7 @@ class SshKey public function generate() { $tempPath = sys_get_temp_dir() . '/'; - - // FastCGI fix for Windows machines, where temp path is not available to - // PHP, and defaults to the unwritable system directory. If the temp - // path is pointing to the system directory, shift to the 'TEMP' - // sub-folder, which should also exist, but actually be writable. - if (IS_WIN && $tempPath == getenv("SystemRoot") . '/') { - $tempPath = getenv("SystemRoot") . '/TEMP/'; - } - - $keyFile = $tempPath . md5(microtime(true)); + $keyFile = $tempPath . md5(microtime(true)); if (!is_dir($tempPath)) { mkdir($tempPath); diff --git a/src/PHPCensor/Helper/WindowsCommandExecutor.php b/src/PHPCensor/Helper/WindowsCommandExecutor.php deleted file mode 100644 index fb3128b4..00000000 --- a/src/PHPCensor/Helper/WindowsCommandExecutor.php +++ /dev/null @@ -1,30 +0,0 @@ -handleSymlink($builder, $reference, $buildPath); } else { $cmd = 'cp -Rf "%s" "%s/"'; - if (IS_WIN) { - $cmd = 'xcopy /E /Y "%s" "%s/*"'; - } $builder->executeCommand($cmd, $reference, $buildPath); } diff --git a/src/PHPCensor/Model/Build/RemoteGitBuild.php b/src/PHPCensor/Model/Build/RemoteGitBuild.php index 3ce2391b..fea49cee 100644 --- a/src/PHPCensor/Model/Build/RemoteGitBuild.php +++ b/src/PHPCensor/Model/Build/RemoteGitBuild.php @@ -77,11 +77,8 @@ class RemoteGitBuild extends Build */ protected function cloneBySsh(Builder $builder, $cloneTo) { - $keyFile = $this->writeSshKey($cloneTo); - - if (!IS_WIN) { - $gitSshWrapper = $this->writeSshWrapper($cloneTo, $keyFile); - } + $keyFile = $this->writeSshKey($cloneTo); + $gitSshWrapper = $this->writeSshWrapper($cloneTo, $keyFile); // Do the git clone: $cmd = 'git clone --recursive '; @@ -93,10 +90,7 @@ class RemoteGitBuild extends Build } $cmd .= ' -b %s %s "%s"'; - - if (!IS_WIN) { - $cmd = 'export GIT_SSH="'.$gitSshWrapper.'" && ' . $cmd; - } + $cmd = 'export GIT_SSH="'.$gitSshWrapper.'" && ' . $cmd; $success = $builder->executeCommand($cmd, $this->getBranch(), $this->getCloneUrl(), $cloneTo); @@ -106,9 +100,7 @@ class RemoteGitBuild extends Build // Remove the key file and git wrapper: unlink($keyFile); - if (!IS_WIN) { - unlink($gitSshWrapper); - } + unlink($gitSshWrapper); return $success; } @@ -122,9 +114,8 @@ class RemoteGitBuild extends Build protected function postCloneSetup(Builder $builder, $cloneTo) { $success = true; - $commit = $this->getCommitId(); - - $chdir = IS_WIN ? 'cd /d "%s"' : 'cd "%s"'; + $commit = $this->getCommitId(); + $chdir = 'cd "%s"'; if (!empty($commit) && $commit != 'Manual') { $cmd = $chdir . ' && git checkout %s --quiet'; diff --git a/src/PHPCensor/Model/Build/SubversionBuild.php b/src/PHPCensor/Model/Build/SubversionBuild.php index b74570c7..9eb5586f 100644 --- a/src/PHPCensor/Model/Build/SubversionBuild.php +++ b/src/PHPCensor/Model/Build/SubversionBuild.php @@ -119,19 +119,15 @@ class SubversionBuild extends Build { $cmd = $this->svnCommand . ' %s "%s"'; - if (!IS_WIN) { - $keyFile = $this->writeSshKey($cloneTo); - $sshWrapper = $this->writeSshWrapper($cloneTo, $keyFile); - $cmd = 'export SVN_SSH="' . $sshWrapper . '" && ' . $cmd; - } + $keyFile = $this->writeSshKey($cloneTo); + $sshWrapper = $this->writeSshWrapper($cloneTo, $keyFile); + $cmd = 'export SVN_SSH="' . $sshWrapper . '" && ' . $cmd; $success = $builder->executeCommand($cmd, $this->getCloneUrl(), $cloneTo); - if (!IS_WIN) { - // Remove the key file and svn wrapper: - unlink($keyFile); - unlink($sshWrapper); - } + // Remove the key file and svn wrapper: + unlink($keyFile); + unlink($sshWrapper); return $success; } diff --git a/src/PHPCensor/Plugin/CleanBuild.php b/src/PHPCensor/Plugin/CleanBuild.php index 37b01fc9..30c33616 100644 --- a/src/PHPCensor/Plugin/CleanBuild.php +++ b/src/PHPCensor/Plugin/CleanBuild.php @@ -49,9 +49,7 @@ class CleanBuild extends Plugin public function execute() { $cmd = 'rm -Rf "%s"'; - if (IS_WIN) { - $cmd = 'rmdir /S /Q "%s"'; - } + $this->builder->executeCommand($cmd, $this->builder->buildPath . 'composer.phar'); $this->builder->executeCommand($cmd, $this->builder->buildPath . 'composer.lock'); diff --git a/src/PHPCensor/Plugin/Codeception.php b/src/PHPCensor/Plugin/Codeception.php index c4cf0d5e..8bd31519 100644 --- a/src/PHPCensor/Plugin/Codeception.php +++ b/src/PHPCensor/Plugin/Codeception.php @@ -129,10 +129,6 @@ class Codeception extends Plugin implements ZeroConfigPluginInterface $cmd = 'cd "%s" && ' . $codeception . ' run -c "%s" --xml ' . $this->args; - if (IS_WIN) { - $cmd = 'cd /d "%s" && ' . $codeception . ' run -c "%s" --xml ' . $this->args; - } - $configPath = $this->builder->buildPath . $configPath; $success = $this->builder->executeCommand($cmd, $this->builder->buildPath, $configPath); diff --git a/src/PHPCensor/Plugin/Composer.php b/src/PHPCensor/Plugin/Composer.php index 3cfe0980..1d34fdc6 100644 --- a/src/PHPCensor/Plugin/Composer.php +++ b/src/PHPCensor/Plugin/Composer.php @@ -104,14 +104,7 @@ class Composer extends Plugin implements ZeroConfigPluginInterface public function execute() { $composerLocation = $this->builder->findBinary(['composer', 'composer.phar']); - - $cmd = ''; - - if (IS_WIN) { - $cmd = 'php '; - } - - $cmd .= $composerLocation . ' --no-ansi --no-interaction '; + $cmd = $composerLocation . ' --no-ansi --no-interaction '; if ($this->preferDist) { $this->builder->log('Using --prefer-dist flag'); diff --git a/src/PHPCensor/Plugin/CopyBuild.php b/src/PHPCensor/Plugin/CopyBuild.php index 9716ab5a..38afbe32 100644 --- a/src/PHPCensor/Plugin/CopyBuild.php +++ b/src/PHPCensor/Plugin/CopyBuild.php @@ -62,9 +62,6 @@ class CopyBuild extends Plugin $this->wipeExistingDirectory(); $cmd = 'mkdir -p "%s" && cp -R "%s" "%s"'; - if (IS_WIN) { - $cmd = 'mkdir -p "%s" && xcopy /E "%s" "%s"'; - } $success = $this->builder->executeCommand($cmd, $this->directory, $build, $this->directory); @@ -97,9 +94,6 @@ class CopyBuild extends Plugin if ($this->ignore) { foreach ($this->builder->ignore as $file) { $cmd = 'rm -Rf "%s/%s"'; - if (IS_WIN) { - $cmd = 'rmdir /S /Q "%s\%s"'; - } $this->builder->executeCommand($cmd, $this->directory, $file); } } diff --git a/src/PHPCensor/Plugin/Grunt.php b/src/PHPCensor/Plugin/Grunt.php index 6cdf8256..6810a614 100644 --- a/src/PHPCensor/Plugin/Grunt.php +++ b/src/PHPCensor/Plugin/Grunt.php @@ -74,18 +74,12 @@ class Grunt extends Plugin { // if npm does not work, we cannot use grunt, so we return false $cmd = 'cd %s && npm install'; - if (IS_WIN) { - $cmd = 'cd /d %s && npm install'; - } if (!$this->builder->executeCommand($cmd, $this->directory)) { return false; } // build the grunt command $cmd = 'cd %s && ' . $this->grunt; - if (IS_WIN) { - $cmd = 'cd /d %s && ' . $this->grunt; - } $cmd .= ' --no-color'; $cmd .= ' --gruntfile %s'; $cmd .= ' %s'; // the task that will be executed diff --git a/src/PHPCensor/Plugin/Gulp.php b/src/PHPCensor/Plugin/Gulp.php index 72110921..adb88c2f 100644 --- a/src/PHPCensor/Plugin/Gulp.php +++ b/src/PHPCensor/Plugin/Gulp.php @@ -74,18 +74,12 @@ class Gulp extends Plugin { // if npm does not work, we cannot use gulp, so we return false $cmd = 'cd %s && npm install'; - if (IS_WIN) { - $cmd = 'cd /d %s && npm install'; - } if (!$this->builder->executeCommand($cmd, $this->directory)) { return false; } // build the gulp command $cmd = 'cd %s && ' . $this->gulp; - if (IS_WIN) { - $cmd = 'cd /d %s && ' . $this->gulp; - } $cmd .= ' --no-color'; $cmd .= ' --gulpfile %s'; $cmd .= ' %s'; // the task that will be executed diff --git a/src/PHPCensor/Plugin/Wipe.php b/src/PHPCensor/Plugin/Wipe.php index 4da96a95..7dc3f7cb 100644 --- a/src/PHPCensor/Plugin/Wipe.php +++ b/src/PHPCensor/Plugin/Wipe.php @@ -55,11 +55,10 @@ class Wipe extends Plugin } if (is_dir($this->directory)) { $cmd = 'rm -Rf "%s"'; - if (IS_WIN) { - $cmd = 'rmdir /S /Q "%s"'; - } + return $this->builder->executeCommand($cmd, $this->directory); } + return true; } } diff --git a/src/PHPCensor/ProcessControl/Factory.php b/src/PHPCensor/ProcessControl/Factory.php index 32d263aa..4ccd57ef 100644 --- a/src/PHPCensor/ProcessControl/Factory.php +++ b/src/PHPCensor/ProcessControl/Factory.php @@ -42,18 +42,14 @@ class Factory * Check PosixProcessControl, WindowsProcessControl and UnixProcessControl, in that order. * * @return ProcessControlInterface - * - * @internal + * + * @throws \Exception */ public static function createProcessControl() { switch (true) { case PosixProcessControl::isAvailable(): return new PosixProcessControl(); - - case WindowsProcessControl::isAvailable(): - return new WindowsProcessControl(); - case UnixProcessControl::isAvailable(): return new UnixProcessControl(); } diff --git a/src/PHPCensor/ProcessControl/WindowsProcessControl.php b/src/PHPCensor/ProcessControl/WindowsProcessControl.php deleted file mode 100644 index 24b3868a..00000000 --- a/src/PHPCensor/ProcessControl/WindowsProcessControl.php +++ /dev/null @@ -1,56 +0,0 @@ - - */ -class WindowsProcessControl implements ProcessControlInterface -{ - /** - * Check if the process is running using the "tasklist" command. - * - * @param integer $pid - * - * @return bool - */ - public function isRunning($pid) - { - $lastLine = exec(sprintf('tasklist /fi "PID eq %d" /nh /fo csv 2>nul:', $pid)); - $record = str_getcsv($lastLine); - return isset($record[1]) && intval($record[1]) === $pid; - } - - /** - * {@inheritdoc} - */ - public function kill($pid, $forcefully = false) - { - $result = 1; - - exec(sprintf("taskkill /t /pid %d %s 2>nul:", $pid, $forcefully ? '/f' : '')); - - return !$result; - } - - /** - * Check whether the commands "tasklist" and "taskkill" are available. - * - * @return bool - * - * @internal - */ - public static function isAvailable() - { - return DIRECTORY_SEPARATOR === '\\' && exec("where tasklist") && exec("where taskkill"); - } -} diff --git a/tests/PHPCensor/Helper/CommandExecutorTest.php b/tests/PHPCensor/Helper/CommandExecutorTest.php index 0439ffa2..d719622d 100644 --- a/tests/PHPCensor/Helper/CommandExecutorTest.php +++ b/tests/PHPCensor/Helper/CommandExecutorTest.php @@ -21,17 +21,11 @@ class CommandExecutorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - if (IS_WIN) { - $this->markTestSkipped("Cannot test UnixCommandExecutor on ".PHP_OS); - return; - } parent::setUp(); $mockBuildLogger = $this->prophesize('PHPCensor\Logging\BuildLogger'); - $class = IS_WIN - ? 'PHPCensor\Helper\WindowsCommandExecutor' - : 'PHPCensor\Helper\UnixCommandExecutor'; + $class = 'PHPCensor\Helper\UnixCommandExecutor'; $this->testedExecutor = new $class($mockBuildLogger->reveal(), __DIR__); } diff --git a/tests/PHPCensor/ProcessControl/WindowsProcessControlTest.php b/tests/PHPCensor/ProcessControl/WindowsProcessControlTest.php deleted file mode 100644 index 91d3d2eb..00000000 --- a/tests/PHPCensor/ProcessControl/WindowsProcessControlTest.php +++ /dev/null @@ -1,22 +0,0 @@ -object = new WindowsProcessControl(); - } - - public function getTestCommand() - { - return "pause"; - } - - public function testIsAvailable() - { - $this->assertEquals(DIRECTORY_SEPARATOR === '\\', WindowsProcessControl::isAvailable()); - } -} diff --git a/tests/PHPCensor/Security/Authentication/ServiceTest.php b/tests/PHPCensor/Security/Authentication/ServiceTest.php index 7e628e93..793f8c66 100644 --- a/tests/PHPCensor/Security/Authentication/ServiceTest.php +++ b/tests/PHPCensor/Security/Authentication/ServiceTest.php @@ -14,17 +14,11 @@ use PHPCensor\Security\Authentication\Service; class ServiceTest extends \PHPUnit_Framework_TestCase { - /** - * @covers Service::getInstance - */ public function testGetInstance() { $this->assertInstanceOf('\PHPCensor\Security\Authentication\Service', Service::getInstance()); } - /** - * @covers Service::buildProvider - */ public function testBuildBuiltinProvider() { $provider = Service::buildProvider('test', ['type' => 'internal']); @@ -32,9 +26,6 @@ class ServiceTest extends \PHPUnit_Framework_TestCase $this->assertInstanceOf('\PHPCensor\Security\Authentication\UserProvider\Internal', $provider); } - /** - * @covers Service::buildProvider - */ public function testBuildAnyProvider() { $config = ['type' => '\Tests\PHPCensor\Security\Authentication\DummyProvider']; @@ -45,9 +36,6 @@ class ServiceTest extends \PHPUnit_Framework_TestCase $this->assertEquals($config, $provider->config); } - /** - * @covers Service::getProviders - */ public function testGetProviders() { $a = $this->prophesize('\PHPCensor\Security\Authentication\UserProviderInterface')->reveal(); @@ -59,9 +47,6 @@ class ServiceTest extends \PHPUnit_Framework_TestCase $this->assertEquals($providers, $service->getProviders()); } - /** - * @covers Service::getLoginPasswordProviders - */ public function testGetLoginPasswordProviders() { $a = $this->prophesize('\PHPCensor\Security\Authentication\UserProviderInterface')->reveal(); diff --git a/tests/PHPCensor/Security/Authentication/UserProvider/InternalTest.php b/tests/PHPCensor/Security/Authentication/UserProvider/InternalTest.php index a8984e9f..08241db7 100644 --- a/tests/PHPCensor/Security/Authentication/UserProvider/InternalTest.php +++ b/tests/PHPCensor/Security/Authentication/UserProvider/InternalTest.php @@ -27,9 +27,6 @@ class InternalTest extends \PHPUnit_Framework_TestCase ]); } - /** - * @covers Internal::verifyPassword - */ public function testVerifyPassword() { $user = new User(); @@ -39,9 +36,6 @@ class InternalTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->provider->verifyPassword($user, $password)); } - /** - * @covers Internal::verifyPassword - */ public function testVerifyInvaldPassword() { $user = new User(); @@ -51,17 +45,11 @@ class InternalTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->provider->verifyPassword($user, 'bar')); } - /** - * @covers Internal::checkRequirements - */ public function testCheckRequirements() { $this->provider->checkRequirements(); } - /** - * @covers Internal::provisionUser - */ public function testProvisionUser() { $this->assertNull($this->provider->provisionUser('john@doe.com')); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index b36266f6..beb32935 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -33,10 +33,6 @@ if (!defined('RUNTIME_DIR')) { define('RUNTIME_DIR', ROOT_DIR . 'runtime' . DIRECTORY_SEPARATOR); } -if (!defined('IS_WIN')) { - define('IS_WIN', ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false)); -} - require_once(ROOT_DIR . 'vendor/autoload.php'); // Load configuration if present: From 327f442ebb9e66448907625b3325f3302be20695 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Thu, 2 Feb 2017 19:32:17 +0700 Subject: [PATCH 05/13] Small content fixes --- README.md | 2 +- composer.json | 4 +- docs/en/README.md | 2 +- docs/en/config.md | 62 -------------------- docs/en/configuring.md | 53 ++++++++++++++--- docs/en/configuring_project.md | 75 ++++++++++++++++++++++++ docs/en/plugins/email.md | 3 +- src/PHPCensor/Command/InstallCommand.php | 3 + src/PHPCensor/Plugin/Util/Executor.php | 1 - 9 files changed, 127 insertions(+), 78 deletions(-) delete mode 100644 docs/en/config.md create mode 100644 docs/en/configuring_project.md diff --git a/README.md b/README.md index 7f6c7415..ee59add4 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ complete: default_mailto_address: admin@php-censor.local ``` -More details about [configuring project](docs/en/config.md). +More details about [configuring project](docs/en/configuring_project.md). Installing ---------- diff --git a/composer.json b/composer.json index 5d40f176..715e7e29 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { "name": "corpsee/php-censor", - "description": "PHP Censor is a fork of PHPCI and is a open source continuous integration tool specifically designed for PHP", + "description": "PHP Censor is a open source self-hosted continuous integration server for PHP projects (Fork of PHPCI)", "minimum-stability": "stable", "type": "application", - "keywords": ["php", "php-censor", "ci", "continuous integration"], + "keywords": ["php", "php-censor", "phpci", "ci-server", "testing", "self-hosted", "open-source", "ci", "continuous integration"], "homepage": "https://github.com/corpsee/php-censor", "license": "BSD-2-Clause", "authors": [ diff --git a/docs/en/README.md b/docs/en/README.md index ab0057de..9f596185 100644 --- a/docs/en/README.md +++ b/docs/en/README.md @@ -8,7 +8,7 @@ Getting Started * [Adding a Virtual Host](virtual_host.md) * [Run builds using a worker](workers/worker.md) * [Run builds using cronjob](workers/cron.md) -* [Adding PHP Censor Support to Your Projects](config.md) +* [Adding PHP Censor Support to Your Projects](configuring_project.md) * [Setting up Logging](logging.md) * [Updating PHP Censor](updating.md) * [Configuring PHP Censor](configuring.md) diff --git a/docs/en/config.md b/docs/en/config.md deleted file mode 100644 index 29027ecd..00000000 --- a/docs/en/config.md +++ /dev/null @@ -1,62 +0,0 @@ -Adding PHP Censor Support to Your Projects -========================================== - -Similar to Travis CI, to support PHP Censor in your project, you simply need to add a `.php-censor.yml` (`phpci.yml`/`.phpci.yml` for backward compatibility with PHPCI) file to the root of -your repository. The file should look something like this: - -```yml -build_settings: - clone_depth: 1 # depth of 1 is a shallow clone, remove this line to clone entire repo - ignore: - - "vendor" - - "tests" - mysql: - host: "localhost" - user: "root" - pass: "" - -setup: - mysql: - - "DROP DATABASE IF EXISTS test;" - - "CREATE DATABASE test;" - - "GRANT ALL PRIVILEGES ON test.* TO test@'localhost' IDENTIFIED BY 'test';" - composer: - action: "install" - -test: - php_unit: - config: - - "PHPUnit-all.xml" - - "PHPUnit-ubuntu-fix.xml" - directory: - - "tests/" - run_from: "phpunit/" - coverage: "tests/logs/coverage" - php_mess_detector: - allow_failures: true - php_code_sniffer: - standard: "PSR2" - php_cpd: - allow_failures: true - grunt: - task: "build" - -complete: - mysql: - host: "localhost" - user: "root" - pass: "" - - "DROP DATABASE IF EXISTS test;" -``` - -As mentioned earlier, PHP Censor is powered by plugins, there are several phases in which plugins can be run: - -* `setup` - This phase is designed to initialise the build procedure. -* `test` - The tests that should be run during the build. Plugins run during this phase will contribute to the success or failure of the build. -* `complete` - Always called when the `test` phase completes, regardless of success or failure. **Note** that is you do any DB stuff here, you will need to add the DB credentials to this section as well, as it runs in a separate instance. -* `success` - Called upon success of the `test` phase. -* `failure` - Called upon failure of the `test` phase. -* `fixed` - Called upon success of the `test` phase if the previous build of the branch was a success. -* `broken` - Called upon failure of the `test` phase if the previous build of the branch was a failure. - -The `ignore` section is merely an array of paths that should be ignored in all tests (where possible.) diff --git a/docs/en/configuring.md b/docs/en/configuring.md index 62cb30b0..777e18a9 100644 --- a/docs/en/configuring.md +++ b/docs/en/configuring.md @@ -4,17 +4,52 @@ Configuring PHP Censor The PHP Censor configuration on the server is automatically generated into the `config.yml` file during installation. One might need to also edit the file manually. -For example, one could log into PHP Censor and go into the settings to disable it. But if you have already set up a -username/password pair and have forgotten the password, and if the server is on a local network, and it's not sending -the `forgot password` email, then editing the config file manually would be handy. To do so, just edit the `php-censor` -section in the config file (which is in [yaml format](https://en.wikipedia.org/wiki/YAML)), and add +There is `config.yml` example: ```yml +b8: + database: + servers: + read: + - host: localhost + port: 3306 + write: + - host: localhost + port: 3306 + type: mysql # Database type: "mysql" or "pgsql" + name: php-censor-db + username: php-censor-user + password: php-censor-password php-censor: + language: en + per_page: 10 + url: 'http://php-censor.local' + email_settings: + from_address: 'no-reply@php-censor.local' + smtp_address: + queue: + use_queue: true + host: localhost + name: php-censor-queue + lifetime: 600 + github: + token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' + comments: + commit: false # This option allow/deny to post comments to Github commit + pull_request: false # This option allow/deny to post comments to Github Pull Request + build: + remove_builds: true # This option allow/deny build cleaning security: - disable_auth: true - default_user_id: 1 + disable_auth: false # This option allows/deny you to disable authentication for PHP Censor + default_user_id: 1 # Default user when authentication disabled + auth_providers: # Authentication providers + internal: + type: internal # Default provider (PHP Censor internal authentication) + ldap: + type: ldap # Your LDAP provider + data: + host: 'ldap.php-censor.local' + port: 389 + base_dn: 'dc=php-censor,dc=local' + mail_attribute: mail ``` - -where you can get the `default_user_id` by logging into the database and selecting your user ID from the `users` table in -the PHP Censor database. diff --git a/docs/en/configuring_project.md b/docs/en/configuring_project.md new file mode 100644 index 00000000..434d83a7 --- /dev/null +++ b/docs/en/configuring_project.md @@ -0,0 +1,75 @@ +Adding PHP Censor Support to Your Projects +========================================== + +Similar to Travis CI, to support PHP Censor in your project, you simply need to add a `.php-censor.yml` +(`phpci.yml`/`.phpci.yml` for backward compatibility with PHPCI) file to the root of your repository. The file should +look something like this: + +```yml +build_settings: + clone_depth: 1 # depth of 1 is a shallow clone, remove this line to clone entire repo + ignore: + - "vendor" + - "tests" + mysql: + host: "localhost" + user: "root" + pass: "" + +setup: + mysql: + - "DROP DATABASE IF EXISTS test;" + - "CREATE DATABASE test;" + - "GRANT ALL PRIVILEGES ON test.* TO test@'localhost' IDENTIFIED BY 'test';" + composer: + action: "install" + +test: + php_unit: + config: + - "PHPUnit-all.xml" + - "PHPUnit-ubuntu-fix.xml" + directory: + - "tests/" + run_from: "phpunit/" + coverage: "tests/logs/coverage" + php_mess_detector: + allow_failures: true + php_code_sniffer: + standard: "PSR2" + php_cpd: + allow_failures: true + grunt: + task: "build" + +complete: + mysql: + host: "localhost" + user: "root" + pass: "" + - "DROP DATABASE IF EXISTS test;" + +branch-dev: # Branch-specific config (for "dev" branch) + run-option: replace # "run-option" parameter can be set to 'replace', 'after' or 'before' + test: + grunt: + task: "build-dev" +``` + +As mentioned earlier, PHP Censor is powered by plugins, there are several phases in which plugins can be run: + +* `setup` - This phase is designed to initialise the build procedure. + +* `test` - The tests that should be run during the build. Plugins run during this phase will contribute to the success or failure of the build. + +* `complete` - Always called when the `test` phase completes, regardless of success or failure. **Note** that is you do any DB stuff here, you will need to add the DB credentials to this section as well, as it runs in a separate instance. + +* `success` - Called upon success of the `test` phase. + +* `failure` - Called upon failure of the `test` phase. + +* `fixed` - Called upon success of the `test` phase if the previous build of the branch was a success. + +* `broken` - Called upon failure of the `test` phase if the previous build of the branch was a failure. + +The `ignore` section is merely an array of paths that should be ignored in all tests (where possible). diff --git a/docs/en/plugins/email.md b/docs/en/plugins/email.md index 23d15675..996fdaa2 100644 --- a/docs/en/plugins/email.md +++ b/docs/en/plugins/email.md @@ -14,12 +14,11 @@ Configuration * **cc** - A list of addresses that will receive a copy of every emails sent. * **template** - The template to use, options are short and long. Default is short on success and long otherwise. - **Note:** _This plugin will only work if you configured email settings during installation or configured them later in Admin Options > Settings > Email Settings_ ### Examples -See [Adding PHP Censor Support to Your Projects](../config.md) for more information about how to configure plugins. +See [Adding PHP Censor Support to Your Projects](../configuring_project.md) for more information about how to configure plugins. Send an email to the committer as well as one@exameple.com if a build fails: ```yml diff --git a/src/PHPCensor/Command/InstallCommand.php b/src/PHPCensor/Command/InstallCommand.php index d3a7c4bc..ba59c918 100644 --- a/src/PHPCensor/Command/InstallCommand.php +++ b/src/PHPCensor/Command/InstallCommand.php @@ -268,6 +268,9 @@ class InstallCommand extends Command { $skipQueueConfig = [ 'queue-use' => false, + 'host' => null, + 'name' => null, + 'lifetime' => 600 ]; if (!$input->getOption('queue-use')) { diff --git a/src/PHPCensor/Plugin/Util/Executor.php b/src/PHPCensor/Plugin/Util/Executor.php index 8af07545..17721af7 100644 --- a/src/PHPCensor/Plugin/Util/Executor.php +++ b/src/PHPCensor/Plugin/Util/Executor.php @@ -93,7 +93,6 @@ class Executor $plugins = $branchConfig[$stage]; $runOption = 'after'; - if (!empty($branchConfig['run-option'])) { $runOption = $branchConfig['run-option']; } From 97cd0b5373bcc1e8ed0b1e5e1931cde779ea9622 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Thu, 2 Feb 2017 21:55:29 +0700 Subject: [PATCH 06/13] Improved tables appearance --- public/assets/js/build-plugins/codeception.js | 2 +- public/assets/js/build-plugins/phptallint.js | 4 ++-- public/assets/js/build-plugins/phpunit.js | 4 ++-- public/assets/js/build-plugins/summary.js | 4 ++-- src/PHPCensor/View/Build/view.phtml | 2 +- src/PHPCensor/View/Group/index.phtml | 2 +- src/PHPCensor/View/Project/view.phtml | 2 +- src/PHPCensor/View/User/index.phtml | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/public/assets/js/build-plugins/codeception.js b/public/assets/js/build-plugins/codeception.js index 67ec8846..71ed55a7 100644 --- a/public/assets/js/build-plugins/codeception.js +++ b/public/assets/js/build-plugins/codeception.js @@ -31,7 +31,7 @@ var codeceptionPlugin = ActiveBuild.UiPlugin.extend({ }, render: function() { - return $('' + + return $('
' + '' + '' + '' + diff --git a/public/assets/js/build-plugins/phptallint.js b/public/assets/js/build-plugins/phptallint.js index 891f84fc..3381af69 100644 --- a/public/assets/js/build-plugins/phptallint.js +++ b/public/assets/js/build-plugins/phptallint.js @@ -22,14 +22,14 @@ var phptalPlugin = ActiveBuild.UiPlugin.extend({ }, render: function() { - return $('
'+Lang.get('codeception_suite')+''+Lang.get('codeception_feature')+'
' + + return $('
' + '' + '' + ' ' + ' ' + ' ' + '' + - '
' + Lang.get('file') + '' + Lang.get('line') + '' + Lang.get('message') + '
'); + ''); }, onUpdate: function(e) { diff --git a/public/assets/js/build-plugins/phpunit.js b/public/assets/js/build-plugins/phpunit.js index 9f7f61b1..e345c4a0 100644 --- a/public/assets/js/build-plugins/phpunit.js +++ b/public/assets/js/build-plugins/phpunit.js @@ -32,14 +32,14 @@ var phpunitPlugin = ActiveBuild.UiPlugin.extend({ render: function() { - return $('
' + + return $('
' + '' + '' + '' + '' + '' + '' + - '
'+Lang.get('status')+''+Lang.get('test_message')+''+Lang.get('trace')+'
'); + ''); }, onUpdate: function(e) { diff --git a/public/assets/js/build-plugins/summary.js b/public/assets/js/build-plugins/summary.js index af2e0186..ecffe894 100644 --- a/public/assets/js/build-plugins/summary.js +++ b/public/assets/js/build-plugins/summary.js @@ -21,13 +21,13 @@ var SummaryPlugin = ActiveBuild.UiPlugin.extend({ render: function() { return $( - '
' + + '
' + '' + '' + '' + '' + '' + - '
'+Lang.get('stage')+''+Lang.get('plugin')+''+Lang.get('status')+'' + Lang.get('duration') + ' (' + Lang.get('seconds') + ')
' + '' ); }, diff --git a/src/PHPCensor/View/Build/view.phtml b/src/PHPCensor/View/Build/view.phtml index 8f048f3b..2b515a02 100644 --- a/src/PHPCensor/View/Build/view.phtml +++ b/src/PHPCensor/View/Build/view.phtml @@ -140,7 +140,7 @@
- +
diff --git a/src/PHPCensor/View/Group/index.phtml b/src/PHPCensor/View/Group/index.phtml index b9041ca4..7bad7e89 100644 --- a/src/PHPCensor/View/Group/index.phtml +++ b/src/PHPCensor/View/Group/index.phtml @@ -6,7 +6,7 @@
-
+
diff --git a/src/PHPCensor/View/Project/view.phtml b/src/PHPCensor/View/Project/view.phtml index b0a86a06..f01bc5f7 100644 --- a/src/PHPCensor/View/Project/view.phtml +++ b/src/PHPCensor/View/Project/view.phtml @@ -49,7 +49,7 @@

()

-
+
diff --git a/src/PHPCensor/View/User/index.phtml b/src/PHPCensor/View/User/index.phtml index c6675455..6eb77906 100644 --- a/src/PHPCensor/View/User/index.phtml +++ b/src/PHPCensor/View/User/index.phtml @@ -9,7 +9,7 @@
-
+
From 0a4636a3790f736b40a3b72fb82ba86b2d084ab2 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Sat, 4 Feb 2017 17:34:19 +0700 Subject: [PATCH 07/13] Refactored InstallCommand (+ removed localization from InstallCommand, because it doesn't works actually) --- app/config.example.yml | 45 --- composer.json | 8 +- composer.lock | 22 +- docs/en/configuring.md | 8 +- src/B8Framework/Database.php | 2 +- src/PHPCensor/Command/CreateAdminCommand.php | 12 +- src/PHPCensor/Command/InstallCommand.php | 294 +++++++++--------- src/PHPCensor/Helper/Lang.php | 2 +- src/PHPCensor/Languages/lang.da.php | 36 --- src/PHPCensor/Languages/lang.de.php | 36 --- src/PHPCensor/Languages/lang.el.php | 36 --- src/PHPCensor/Languages/lang.en.php | 37 --- src/PHPCensor/Languages/lang.es.php | 36 --- src/PHPCensor/Languages/lang.fr.php | 36 --- src/PHPCensor/Languages/lang.it.php | 37 --- src/PHPCensor/Languages/lang.nl.php | 36 --- src/PHPCensor/Languages/lang.pl.php | 36 --- src/PHPCensor/Languages/lang.pt-br.php | 36 --- src/PHPCensor/Languages/lang.ru.php | 37 --- src/PHPCensor/Languages/lang.uk.php | 36 --- src/PHPCensor/Languages/lang.zh.php | 36 --- .../PHPCensor/Command/InstallCommandTest.php | 27 +- 22 files changed, 197 insertions(+), 694 deletions(-) delete mode 100644 app/config.example.yml diff --git a/app/config.example.yml b/app/config.example.yml deleted file mode 100644 index eeb36973..00000000 --- a/app/config.example.yml +++ /dev/null @@ -1,45 +0,0 @@ -b8: - database: - servers: - read: - - host: localhost - port: 3306 - write: - - host: localhost - port: 3306 - type: mysql - name: php-censor-db - username: php-censor-user - password: php-censor-password -php-censor: - language: en - per_page: 10 - url: 'http://php-censor.local' - email_settings: - from_address: 'no-reply@php-censor.local' - smtp_address: - queue: - use_queue: true - host: localhost - name: php-censor-queue - lifetime: 600 - github: - token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' - comments: - commit: false - pull_request: false - build: - remove_builds: true - security: - disable_auth: false - default_user_id: 1 - auth_providers: - internal: - type: internal - ldap: - type: ldap - data: - host: 'ldap.php-censor.local' - port: 389 - base_dn: 'dc=php-censor,dc=local' - mail_attribute: mail diff --git a/composer.json b/composer.json index 715e7e29..6b4049fc 100644 --- a/composer.json +++ b/composer.json @@ -37,8 +37,12 @@ } }, "require": { - "php": ">=5.6.0", - "ext-pdo": "*", + "php": ">=5.6.0", + "ext-openssl": "*", + "ext-pdo": "*", + "ext-json": "*", + "ext-xml": "*", + "ext-curl": "*", "swiftmailer/swiftmailer": "5.4.*", "symfony/yaml": "2.8.*", diff --git a/composer.lock b/composer.lock index d6359a02..2f372159 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "991c7a5bd9a73001129408ff55f5a8f1", + "content-hash": "147a1f73282f1c309c8f85a4e9d3bbac", "packages": [ { "name": "bower-asset/admin-lte", @@ -1695,16 +1695,16 @@ }, { "name": "phpunit/phpunit", - "version": "5.7.9", + "version": "5.7.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "69f832b87c731d5cacad7f91948778fe98335fdd" + "reference": "bf0804199f516fe80ffcc48ac6d4741c49baeb6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/69f832b87c731d5cacad7f91948778fe98335fdd", - "reference": "69f832b87c731d5cacad7f91948778fe98335fdd", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/bf0804199f516fe80ffcc48ac6d4741c49baeb6e", + "reference": "bf0804199f516fe80ffcc48ac6d4741c49baeb6e", "shasum": "" }, "require": { @@ -1721,11 +1721,11 @@ "phpunit/php-text-template": "~1.2", "phpunit/php-timer": "^1.0.6", "phpunit/phpunit-mock-objects": "^3.2", - "sebastian/comparator": "~1.2.2", + "sebastian/comparator": "^1.2.4", "sebastian/diff": "~1.2", "sebastian/environment": "^1.3.4 || ^2.0", "sebastian/exporter": "~2.0", - "sebastian/global-state": "^1.0 || ^2.0", + "sebastian/global-state": "^1.1", "sebastian/object-enumerator": "~2.0", "sebastian/resource-operations": "~1.0", "sebastian/version": "~1.0|~2.0", @@ -1773,7 +1773,7 @@ "testing", "xunit" ], - "time": "2017-01-28T06:14:33+00:00" + "time": "2017-02-04T09:03:53+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -2767,7 +2767,11 @@ "prefer-lowest": false, "platform": { "php": ">=5.6.0", - "ext-pdo": "*" + "ext-openssl": "*", + "ext-pdo": "*", + "ext-json": "*", + "ext-xml": "*", + "ext-curl": "*" }, "platform-dev": [] } diff --git a/docs/en/configuring.md b/docs/en/configuring.md index 777e18a9..7d2457e4 100644 --- a/docs/en/configuring.md +++ b/docs/en/configuring.md @@ -25,8 +25,12 @@ php-censor: per_page: 10 url: 'http://php-censor.local' email_settings: - from_address: 'no-reply@php-censor.local' - smtp_address: + from_address: 'no-reply@php-censor.local' + smtp_address: null + smtp_port: null + smtp_username: null + smtp_password: null + smtp_encryption: false queue: use_queue: true host: localhost diff --git a/src/B8Framework/Database.php b/src/B8Framework/Database.php index f11b61b8..f48aef76 100644 --- a/src/B8Framework/Database.php +++ b/src/B8Framework/Database.php @@ -57,7 +57,7 @@ class Database extends \PDO $dns = self::$details['type'] . ':host=' . $server['host']; if (isset($server['port'])) { - $dns .= ';port=' . $server['port']; + $dns .= ';port=' . (integer)$server['port']; } $dns .= ';dbname=' . self::$details['db']; diff --git a/src/PHPCensor/Command/CreateAdminCommand.php b/src/PHPCensor/Command/CreateAdminCommand.php index 1c9223c7..6d661f89 100644 --- a/src/PHPCensor/Command/CreateAdminCommand.php +++ b/src/PHPCensor/Command/CreateAdminCommand.php @@ -61,20 +61,20 @@ class CreateAdminCommand extends Command /** @var $helper QuestionHelper */ $helper = $this->getHelperSet()->get('question'); - $question = new Question(Lang::get('enter_email')); + $question = new Question('Admin email: '); $question->setValidator(function ($answer) { if (!filter_var($answer, FILTER_VALIDATE_EMAIL)) { - throw new \InvalidArgumentException(Lang::get('must_be_valid_email')); + throw new \InvalidArgumentException('Must be a valid email address.'); } return $answer; }); $adminEmail = $helper->ask($input, $output, $question); - $question = new Question(Lang::get('enter_name')); + $question = new Question('Admin name: '); $adminName = $helper->ask($input, $output, $question); - $question = new Question(Lang::get('enter_password')); + $question = new Question('Admin password: '); $question->setHidden(true); $question->setHiddenFallback(false); @@ -82,9 +82,9 @@ class CreateAdminCommand extends Command try { $userService->createUser($adminName, $adminEmail, $adminPass, true); - $output->writeln(Lang::get('user_created')); + $output->writeln('User account created!'); } catch (\Exception $e) { - $output->writeln(sprintf('%s', Lang::get('failed_to_create'))); + $output->writeln(sprintf('%s', 'PHP Censor failed to create your admin account.')); $output->writeln(sprintf('%s', $e->getMessage())); } } diff --git a/src/PHPCensor/Command/InstallCommand.php b/src/PHPCensor/Command/InstallCommand.php index ba59c918..fe8f0ae8 100644 --- a/src/PHPCensor/Command/InstallCommand.php +++ b/src/PHPCensor/Command/InstallCommand.php @@ -1,11 +1,4 @@ - * @package PHPCI - * @subpackage Console + * @author Dan Cryer */ class InstallCommand extends Command { - protected $configFilePath; + /** + * @var string + */ + protected $configPath = APP_DIR . 'config.yml'; protected function configure() { - $defaultPath = APP_DIR . 'config.yml'; - $this ->setName('php-censor:install') - ->addOption('url', null, InputOption::VALUE_OPTIONAL, Lang::get('installation_url')) - ->addOption('db-type', null, InputOption::VALUE_OPTIONAL, Lang::get('db_host')) - ->addOption('db-host', null, InputOption::VALUE_OPTIONAL, Lang::get('db_host')) - ->addOption('db-port', null, InputOption::VALUE_OPTIONAL, Lang::get('db_port')) - ->addOption('db-name', null, InputOption::VALUE_OPTIONAL, Lang::get('db_name')) - ->addOption('db-user', null, InputOption::VALUE_OPTIONAL, Lang::get('db_user')) - ->addOption('db-pass', null, InputOption::VALUE_OPTIONAL, Lang::get('db_pass')) - ->addOption('admin-name', null, InputOption::VALUE_OPTIONAL, Lang::get('admin_name')) - ->addOption('admin-pass', null, InputOption::VALUE_OPTIONAL, Lang::get('admin_pass')) - ->addOption('admin-mail', null, InputOption::VALUE_OPTIONAL, Lang::get('admin_email')) - ->addOption('config-path', null, InputOption::VALUE_OPTIONAL, Lang::get('config_path'), $defaultPath) - ->addOption('queue-use', null, InputOption::VALUE_OPTIONAL, 'Don\'t ask for queue details') - ->addOption('queue-host', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue server hostname') - ->addOption('queue-name', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue name') + ->addOption('url', null, InputOption::VALUE_OPTIONAL, 'PHP Censor installation URL') + ->addOption('db-type', null, InputOption::VALUE_OPTIONAL, 'Database type') + ->addOption('db-host', null, InputOption::VALUE_OPTIONAL, 'Database host') + ->addOption('db-port', null, InputOption::VALUE_OPTIONAL, 'Database port') + ->addOption('db-name', null, InputOption::VALUE_OPTIONAL, 'Database name') + ->addOption('db-user', null, InputOption::VALUE_OPTIONAL, 'Database user') + ->addOption('db-password', null, InputOption::VALUE_OPTIONAL, 'Database password') + ->addOption('admin-name', null, InputOption::VALUE_OPTIONAL, 'Admin name') + ->addOption('admin-password', null, InputOption::VALUE_OPTIONAL, 'Admin password') + ->addOption('admin-email', null, InputOption::VALUE_OPTIONAL, 'Admin email') + ->addOption('queue-use', null, InputOption::VALUE_OPTIONAL, 'Don\'t ask for queue details') + ->addOption('queue-host', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue server hostname') + ->addOption('queue-name', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue name') - ->setDescription(Lang::get('install_app')); + ->setDescription('Install PHP Censor'); } /** - * Installs PHPCI - Can be run more than once as long as you ^C instead of entering an email address. + * Installs PHP Censor */ protected function execute(InputInterface $input, OutputInterface $output) { - $this->configFilePath = $input->getOption('config-path'); - if (!$this->verifyNotInstalled($output)) { return; } $output->writeln(''); - $output->writeln('******************'); - $output->writeln(' '.Lang::get('welcome_to_app').''); - $output->writeln('******************'); + $output->writeln('***************************************'); + $output->writeln('* Welcome to PHP Censor installation *'); + $output->writeln('***************************************'); $output->writeln(''); $this->checkRequirements($output); - $output->writeln(Lang::get('please_answer')); - $output->writeln('-------------------------------------'); + $output->writeln(''); + $output->writeln('Please answer the following questions:'); + $output->writeln('--------------------------------------'); $output->writeln(''); - // ---- - // Get DB connection information and verify that it works: - // ---- $connectionVerified = false; - while (!$connectionVerified) { - $db = $this->getDatabaseInformation($input, $output); - + $db = $this->getDatabaseInformation($input, $output); $connectionVerified = $this->verifyDatabaseDetails($db, $output); } - $output->writeln(''); $conf = []; $conf['b8']['database'] = $db; - // ---- - // Get basic installation details (URL, etc) - // ---- $conf['php-censor'] = $this->getConfigInformation($input, $output); $this->writeConfigFile($conf); @@ -115,58 +96,69 @@ class InstallCommand extends Command $this->createDefaultGroup($output); } + /** + * @param OutputInterface $output + * + * @return bool + */ + protected function verifyNotInstalled(OutputInterface $output) + { + if (file_exists($this->configPath)) { + $content = file_get_contents($this->configPath); + + if (!empty($content)) { + $output->writeln('The PHP Censor config file exists and is not empty. PHP Censor is already installed!'); + return false; + } + } + + return true; + } + /** * Check PHP version, required modules and for disabled functions. * * @param OutputInterface $output + * * @throws \Exception */ protected function checkRequirements(OutputInterface $output) { - $output->write('Checking requirements...'); + $output->writeln('Checking requirements...'); $errors = false; - // Check PHP version: - if (!(version_compare(PHP_VERSION, '5.4.0') >= 0)) { + if (!(version_compare(PHP_VERSION, '5.6.0') >= 0)) { $output->writeln(''); - $output->writeln(''.Lang::get('app_php_req').''); + $output->writeln('PHP Censor requires at least PHP 5.6.0! Installed PHP ' . PHP_VERSION . ''); $errors = true; } - // Check required extensions are present: - $requiredExtensions = ['PDO']; + $requiredExtensions = ['PDO', 'xml', 'json', 'curl', 'openssl']; foreach ($requiredExtensions as $extension) { if (!extension_loaded($extension)) { $output->writeln(''); - $output->writeln(''.Lang::get('extension_required', $extension).''); + $output->writeln('Extension required: ' . $extension . ''); $errors = true; } } - // Check required functions are callable: - $requiredFunctions = ['exec', 'shell_exec']; + $requiredFunctions = ['exec', 'shell_exec', 'proc_open', 'password_hash']; foreach ($requiredFunctions as $function) { if (!function_exists($function)) { $output->writeln(''); - $output->writeln(''.Lang::get('function_required', $function).''); + $output->writeln('PHP Censor needs to be able to call the ' . $function . '() function. Is it disabled in php.ini?'); $errors = true; } } - if (!function_exists('password_hash')) { - $output->writeln(''); - $output->writeln(''.Lang::get('function_required', $function).''); - $errors = true; - } - if ($errors) { - throw new Exception(Lang::get('requirements_not_met')); + throw new Exception('PHP Censor cannot be installed, as not all requirements are met. Please review the errors above before continuing.'); } - $output->writeln(' '.Lang::get('ok').''); $output->writeln(''); + $output->writeln('OK'); } /** @@ -183,37 +175,37 @@ class InstallCommand extends Command /** @var $helper QuestionHelper */ $helper = $this->getHelperSet()->get('question'); - // Function to validate mail address. + // Function to validate email address. $mailValidator = function ($answer) { if (!filter_var($answer, FILTER_VALIDATE_EMAIL)) { - throw new \InvalidArgumentException(Lang::get('must_be_valid_email')); + throw new \InvalidArgumentException('Must be a valid email address.'); } return $answer; }; - if ($adminEmail = $input->getOption('admin-mail')) { + if ($adminEmail = $input->getOption('admin-email')) { $adminEmail = $mailValidator($adminEmail); } else { - $questionEmail = new Question(Lang::get('enter_email')); + $questionEmail = new Question('Admin email: '); $adminEmail = $helper->ask($input, $output, $questionEmail); } if (!$adminName = $input->getOption('admin-name')) { - $questionName = new Question(Lang::get('admin_name')); + $questionName = new Question('Admin name: '); $adminName = $helper->ask($input, $output, $questionName); } - if (!$adminPass = $input->getOption('admin-pass')) { - $questionPass = new Question(Lang::get('enter_password')); + if (!$adminPass = $input->getOption('admin-password')) { + $questionPass = new Question('Admin password: '); $questionPass->setHidden(true); $questionPass->setHiddenFallback(false); $adminPass = $helper->ask($input, $output, $questionPass); } - $admin['mail'] = $adminEmail; - $admin['name'] = $adminName; - $admin['pass'] = $adminPass; + $admin['email'] = $adminEmail; + $admin['name'] = $adminName; + $admin['password'] = $adminPass; return $admin; } @@ -221,20 +213,19 @@ class InstallCommand extends Command /** * Load configuration for PHPCI form CLI options or ask info to user. * - * @param InputInterface $input + * @param InputInterface $input * @param OutputInterface $output + * * @return array */ protected function getConfigInformation(InputInterface $input, OutputInterface $output) { - $config = []; - /** @var $helper QuestionHelper */ $helper = $this->getHelperSet()->get('question'); $urlValidator = function ($answer) { if (!filter_var($answer, FILTER_VALIDATE_URL)) { - throw new Exception(Lang::get('must_be_valid_url')); + throw new Exception('Must be a valid URL.'); } return rtrim($answer, '/'); @@ -243,18 +234,44 @@ class InstallCommand extends Command if ($url = $input->getOption('url')) { $url = $urlValidator($url); } else { - $question = new Question(Lang::get('enter_app_url')); + $question = new Question('Your PHP Censor URL ("http://php-censor.local" for example): '); $question->setValidator($urlValidator); $url = $helper->ask($input, $output, $question); } - $config['language'] = 'en'; - $config['per_page'] = 10; - - $config['url'] = $url; - $config['queue'] = $this->getQueueInformation($input, $output); - - return $config; + return [ + 'language' => 'en', + 'per_page' => 10, + 'url' => $url, + 'queue' => $this->getQueueInformation($input, $output), + 'email_settings' => [ + 'from_address' => 'no-reply@php-censor.local', + 'smtp_address' => null, + 'smtp_port' => null, + 'smtp_username' => null, + 'smtp_password' => null, + 'smtp_encryption' => false, + ], + 'github' => [ + 'token' => null, + 'comments' => [ + 'commit' => false, + 'pull_request' => false, + ], + ], + 'build' => [ + 'remove_builds' => true, + ], + 'security' => [ + 'disable_auth' => false, + 'default_user_id' => 1, + 'auth_providers' => [ + 'default' => [ + 'type' => 'internal', + ], + ], + ], + ]; } /** @@ -262,12 +279,13 @@ class InstallCommand extends Command * * @param InputInterface $input * @param OutputInterface $output + * * @return array */ protected function getQueueInformation(InputInterface $input, OutputInterface $output) { $skipQueueConfig = [ - 'queue-use' => false, + 'use_queue' => false, 'host' => null, 'name' => null, 'lifetime' => 600 @@ -278,7 +296,7 @@ class InstallCommand extends Command } $queueConfig = [ - 'queue-use' => true, + 'use_queue' => true, ]; /** @var $helper QuestionHelper */ @@ -305,10 +323,11 @@ class InstallCommand extends Command } /** - * Load configuration for DB form CLI options or ask info to user. + * Load configuration for database form CLI options or ask info to user. * - * @param InputInterface $input + * @param InputInterface $input * @param OutputInterface $output + * * @return array */ protected function getDatabaseInformation(InputInterface $input, OutputInterface $output) @@ -319,45 +338,50 @@ class InstallCommand extends Command $helper = $this->getHelperSet()->get('question'); if (!$dbType = $input->getOption('db-type')) { - $questionType = new Question(Lang::get('enter_db_type'), 'mysql'); + $questionType = new Question('Please enter your database type (mysql or pgsql): '); $dbType = $helper->ask($input, $output, $questionType); } if (!$dbHost = $input->getOption('db-host')) { - $questionHost = new Question(Lang::get('enter_db_host'), 'localhost'); + $questionHost = new Question('Please enter your database host (default: localhost): ', 'localhost'); $dbHost = $helper->ask($input, $output, $questionHost); } if (!$dbPort = $input->getOption('db-port')) { - $questionPort = new Question(Lang::get('enter_db_port'), '3306'); + $questionPort = new Question('Please enter your database port (default: empty): '); $dbPort = $helper->ask($input, $output, $questionPort); } if (!$dbName = $input->getOption('db-name')) { - $questionDb = new Question(Lang::get('enter_db_name'), 'php-censor-db'); + $questionDb = new Question('Please enter your database name (default: php-censor-db): ', 'php-censor-db'); $dbName = $helper->ask($input, $output, $questionDb); } if (!$dbUser = $input->getOption('db-user')) { - $questionUser = new Question(Lang::get('enter_db_user'), 'php-censor-user'); + $questionUser = new Question('Please enter your DB user (default: php-censor-user): ', 'php-censor-user'); $dbUser = $helper->ask($input, $output, $questionUser); } - if (!$dbPass = $input->getOption('db-pass')) { - $questionPass = new Question(Lang::get('enter_db_pass')); + if (!$dbPass = $input->getOption('db-password')) { + $questionPass = new Question('Please enter your database password: '); $questionPass->setHidden(true); $questionPass->setHiddenFallback(false); $dbPass = $helper->ask($input, $output, $questionPass); } - $db['servers']['read'] = [[ - 'host' => $dbHost, - 'port' => $dbPort, - ]]; - $db['servers']['write'] = [[ - 'host' => $dbHost, - 'port' => $dbPort, - ]]; + $dbServers = [ + [ + 'host' => $dbHost, + ] + ]; + + if ($dbPort) { + $dbServers[0]['port'] = (integer)$dbPort; + } + + $db['servers']['read'] = $dbServers; + $db['servers']['write'] = $dbServers; + $db['type'] = $dbType; $db['name'] = $dbName; $db['username'] = $dbUser; @@ -367,16 +391,24 @@ class InstallCommand extends Command } /** - * Try and connect to DB using the details provided. + * Try and connect to DB using the details provided + * * @param array $db * @param OutputInterface $output + * * @return bool */ protected function verifyDatabaseDetails(array $db, OutputInterface $output) { try { + $dns = $db['type'] . ':host=' . $db['servers']['write'][0]['host']; + if (isset($db['servers']['write'][0]['host'])) { + $dns .= ';port=' . (integer)$db['servers']['write'][0]['host']; + } + $dns .= ';dbname=' . $db['name']; + $pdo = new PDO( - $db['type'] . ':host=' . $db['servers']['write'][0]['host'] . ';port=' . $db['servers']['write'][0]['host'] . 'dbname=' . $db['name'], + $dns, $db['username'], $db['password'], [ @@ -392,7 +424,7 @@ class InstallCommand extends Command return true; } catch (Exception $ex) { - $output->writeln(''.Lang::get('could_not_connect').''); + $output->writeln('PHP Censor could not connect to database with the details provided. Please try again.'); $output->writeln('' . $ex->getMessage() . ''); } @@ -408,16 +440,16 @@ class InstallCommand extends Command $dumper = new Dumper(); $yaml = $dumper->dump($config, 4); - file_put_contents($this->configFilePath, $yaml); + file_put_contents($this->configPath, $yaml); } protected function setupDatabase(OutputInterface $output) { - $output->write(Lang::get('setting_up_db')); + $output->write('Setting up your database...'); shell_exec(ROOT_DIR . 'bin/console php-censor-migrations:migrate'); - $output->writeln(''.Lang::get('ok').''); + $output->writeln('OK'); } /** @@ -431,13 +463,14 @@ class InstallCommand extends Command try { $this->reloadConfig(); - $userStore = Factory::getStore('User'); + /** @var UserStore $userStore */ + $userStore = Factory::getStore('User'); $userService = new UserService($userStore); - $userService->createUser($admin['name'], $admin['mail'], $admin['pass'], 1); + $userService->createUser($admin['name'], $admin['email'], $admin['password'], 1); - $output->writeln(''.Lang::get('user_created').''); + $output->writeln('User account created!'); } catch (\Exception $ex) { - $output->writeln(''.Lang::get('failed_to_create').''); + $output->writeln('PHP Censor failed to create your admin account!'); $output->writeln('' . $ex->getMessage() . ''); } } @@ -453,9 +486,9 @@ class InstallCommand extends Command Factory::getStore('ProjectGroup')->save($group); - $output->writeln(''.Lang::get('default_group_created').''); + $output->writeln('Default project group created!'); } catch (\Exception $ex) { - $output->writeln(''.Lang::get('default_group_failed_to_create').''); + $output->writeln('PHP Censor failed to create default project group!'); $output->writeln('' . $ex->getMessage() . ''); } } @@ -464,27 +497,8 @@ class InstallCommand extends Command { $config = Config::getInstance(); - if (file_exists($this->configFilePath)) { - $config->loadYaml($this->configFilePath); + if (file_exists($this->configPath)) { + $config->loadYaml($this->configPath); } } - - /** - * @param OutputInterface $output - * @return bool - */ - protected function verifyNotInstalled(OutputInterface $output) - { - if (file_exists($this->configFilePath)) { - $content = file_get_contents($this->configFilePath); - - if (!empty($content)) { - $output->writeln(''.Lang::get('config_exists').''); - $output->writeln(''.Lang::get('update_instead').''); - return false; - } - } - - return true; - } } diff --git a/src/PHPCensor/Helper/Lang.php b/src/PHPCensor/Helper/Lang.php index d5fdedeb..c0f4b09c 100644 --- a/src/PHPCensor/Helper/Lang.php +++ b/src/PHPCensor/Helper/Lang.php @@ -59,7 +59,7 @@ class Lang return call_user_func_array('sprintf', $vars); } - return '%%MISSING STRING: ' . $string . '%%'; + return $string; } /** diff --git a/src/PHPCensor/Languages/lang.da.php b/src/PHPCensor/Languages/lang.da.php index 02f02878..4878bc5f 100644 --- a/src/PHPCensor/Languages/lang.da.php +++ b/src/PHPCensor/Languages/lang.da.php @@ -284,42 +284,6 @@ du kører composer update.', 'search_packagist_for_more' => 'Søg på Packagist efter flere pakker', 'search' => 'Søg »', - // Installer - 'installation_url' => 'PHP Censor Installations-URL', - 'db_host' => 'Database-hostnavn', - 'db_name' => 'Database-navn', - 'db_user' => 'Database-brugernavn', - 'db_pass' => 'Database-adgangskode', - 'admin_name' => 'Administrator-navn', - 'admin_pass' => 'Administrator-adgangskode', - 'admin_email' => 'Administrators email-adresse', - 'config_path' => 'Konfigurations-fil', - 'install_app' => 'Installér PHP Censor', - 'welcome_to_app' => 'Velkommen til PHP Censor', - 'please_answer' => 'Besvar venligst følgende spørgsmål:', - 'app_php_req' => 'PHP Censor kræver minimum PHP version 5.4.0 for at fungere.', - 'extension_required' => 'Extension påkrævet: %s', - 'function_required' => 'PHP Censor behøver adgang til funktion %s() i PHP. Er den deaktiveret i php.ini?', - 'requirements_not_met' => 'PHP Censor kan ikke installeres da nogle krav ikke opfyldtes. -Kontrollér venligst nedenstående fejl før du fortsætter.', - 'must_be_valid_email' => 'Skal være en gyldig email-adresse.', - 'must_be_valid_url' => 'Skal være en gyldig URL.', - 'enter_name' => 'Administrator-navn: ', - 'enter_email' => 'Administrators email-adresse: ', - 'enter_password' => 'Administrator-adgangskode: ', - 'enter_app_url' => 'Din PHP Censor URL (eksempelvis "http://php-censor.local"): ', - - 'enter_db_host' => 'Indtast dit DB-hostnavn [localhost]: ', - 'enter_db_name' => 'Indtast dit DB database-navn [php-censor-db]: ', - 'enter_db_user' => 'Indtast dit DB-brugernavn [php-censor-user]: ', - 'enter_db_pass' => 'Indtast dit DB-password: ', - 'could_not_connect' => 'PHP Censor kunne ikke forbinde til DB med de angivning oplysninger. Forsøg igen.', - 'setting_up_db' => 'Indlæser database...', - 'user_created' => 'Brugerkonto oprettet!', - 'failed_to_create' => 'PHP Censor kunne ikke oprette din administrator-konto.', - 'config_exists' => 'PHP Censor konfigurationsfilen findes og er ikke tom.', - 'update_instead' => 'Hvis du forsøgte at opdatere PHP Censor, forsøg da venligst med php-censor:update istedet.', - // Update 'update_app' => 'Opdatér databasen med ændrede modeller', 'updating_app' => 'Opdaterer PHP Censor-database:', diff --git a/src/PHPCensor/Languages/lang.de.php b/src/PHPCensor/Languages/lang.de.php index bbbae40c..880ff6b8 100644 --- a/src/PHPCensor/Languages/lang.de.php +++ b/src/PHPCensor/Languages/lang.de.php @@ -307,42 +307,6 @@ generiert. Um es zu verwenden, fügen Sie einfach den folgenden Public Key im Ab 'stage_broken' => 'Defekt', 'stage_fixed' => 'Behoben', - // Installer - 'installation_url' => 'PHP Censor Installations-URL', - 'db_host' => 'Datenbankserver', - 'db_name' => 'Datenbankname', - 'db_user' => 'Datenbankbenutzer', - 'db_pass' => 'Datenbankpasswort', - 'admin_name' => 'Administratorname', - 'admin_pass' => 'Administratorpasswort', - 'admin_email' => 'Emailadresse des Administrators', - 'config_path' => 'Dateipfad für Konfiguration', - 'install_app' => 'PHP Censor installieren', - 'welcome_to_app' => 'Willkommen bei PHP Censor', - 'please_answer' => 'Bitte beantworten Sie die folgenden Fragen:', - 'app_php_req' => 'PHP Censor benötigt mindestens PHP 5.4.0 um zu funktionieren.', - 'extension_required' => 'Benötigte Extensions: %s', - 'function_required' => 'PHP Censor muss die Funktion %s() aufrufen können. Ist sie in php.ini deaktiviert?', - 'requirements_not_met' => 'PHP Censor konnte nicht installiert werden, weil nicht alle Bedingungen erfüllt sind. - Bitte überprüfen Sie die Fehler, bevor Sie fortfahren,', - 'must_be_valid_email' => 'Muss eine gültige Emailadresse sein.', - 'must_be_valid_url' => 'Muss eine valide URL sein.', - 'enter_name' => 'Name des Administrators: ', - 'enter_email' => 'Emailadresse des Administrators: ', - 'enter_password' => 'Passwort des Administrators: ', - 'enter_app_url' => 'Ihre PHP Censor-URL (z.B. "http://php-censor.local"): ', - - 'enter_db_host' => 'Bitte geben Sie Ihren DB-Host ein [localhost]: ', - 'enter_db_name' => 'Bitte geben Sie Ihren DB-Namen ein [php-censor-db]: ', - 'enter_db_user' => 'Bitte geben Sie Ihren DB-Benutzernamen ein [php-censor-user]: ', - 'enter_db_pass' => 'Bitte geben Sie Ihr DB-Passwort ein: ', - 'could_not_connect' => 'PHP Censor konnte wegen folgender Details nicht mit DB verbinden. Bitte versuchen Sie es erneut.', - 'setting_up_db' => 'Ihre Datenbank wird aufgesetzt... ', - 'user_created' => 'Benutzerkonto wurde erstellt!', - 'failed_to_create' => 'PHP Censor konnte Ihr Administratorenkonto nicht erstellen.', - 'config_exists' => 'Die PHP Censor-Konfigurationsdatei existiert und ist nicht leer..', - 'update_instead' => 'Falls Sie versucht haben PHP Censor zu aktualisieren, benutzen Sie bitte stattdessen php-censor:update.', - // Update 'update_app' => 'Datenbank wird aktualisiert, um den Änderungen der Models zu entsprechen.', 'updating_app' => 'Aktualisiere PHP Censor-Datenbank:', diff --git a/src/PHPCensor/Languages/lang.el.php b/src/PHPCensor/Languages/lang.el.php index 7f143d17..eb11f985 100644 --- a/src/PHPCensor/Languages/lang.el.php +++ b/src/PHPCensor/Languages/lang.el.php @@ -286,42 +286,6 @@ Services του Bitbucket αποθετηρίου σας.', 'search_packagist_for_more' => 'Αναζήτηση στο Packagist για περισσότερα πακέτα', 'search' => 'Αναζήτηση »', - // Installer - 'installation_url' => 'Σύνδεσμος URL εγκατάστασης του PHP Censor', - 'db_host' => 'Φιλοξενία βάσης δεδομένων', - 'db_name' => 'Όνομα βάσης δεδομένων', - 'db_user' => 'Όνομα χρήστη βάσης δεδομένων', - 'db_pass' => 'Κωδικός πρόσβασης βάσης δεδομένων', - 'admin_name' => 'Όνομα διαχειριστή', - 'admin_pass' => 'Κωδικός πρόσβασης διαχειριστή', - 'admin_email' => 'Διεύθυνση email διαχειριστή', - 'config_path' => 'Διαδρομή αρχείου ρυθμίσεων', - 'install_app' => 'Εγκατάσταση PHP Censor', - 'welcome_to_app' => 'Καλώς ήρθατε στο PHP Censor', - 'please_answer' => 'Παρακαλώ απαντήστε στις ακόλουθες ερωτήσεις:', - 'app_php_req' => 'Το PHP Censor απαιτεί τουλάχιστον την έκδοση PHP 5.4.0 για να λειτουργήσει', - 'extension_required' => 'Απαιτούμενη επέκταση: %s ', - 'function_required' => 'Το PHP Censor πρέπει να είναι σε θέση να καλέσει την %s() συνάρτηση. Είναι απενεργοποιημένη στο php.ini;', - 'requirements_not_met' => 'Το PHP Censor δεν μπορεί να εγκατασταθεί, καθώς όλες οι απαιτήσεις δεν ικανοποιούνται. -Παρακαλούμε διαβάστε τα παραπάνω λάθη πριν συνεχίσετε.', - 'must_be_valid_email' => 'Πρέπει να είναι μια έγκυρη διεύθυνση ηλεκτρονικού ταχυδρομείου.', - 'must_be_valid_url' => 'Πρέπει να είναι μια έγκυρη διεύθυνση URL.', - 'enter_name' => 'Όνομα διαχειριστή: ', - 'enter_email' => 'Ηλ. Διεύθυνση διαχειριστή: ', - 'enter_password' => 'Κωδικός πρόσβασης διαχειριστή: ', - 'enter_app_url' => 'Ο URL σύνδεσμος σας για το PHP Censor ("http://php-censor.local" για παράδειγμα): ', - - 'enter_db_host' => 'Παρακαλώ εισάγετε τον DB οικοδεσπότη σας [localhost]: ', - 'enter_db_name' => 'Παρακαλώ εισάγετε το όνομα της DB βάσης δεδομένων σας [php-censor-db]: ', - 'enter_db_user' => 'Παρακαλώ εισάγετε το όνομα χρήστη της DB σας [php-censor-user]: ', - 'enter_db_pass' => 'Παρακαλώ εισάγετε τον κωδικό χρήστη της DB σας: ', - 'could_not_connect' => 'Το PHP Censor δεν μπόρεσε να συνδεθεί με την DB με τα στοχεία που δώσατε. Παρακαλώ δοκιμάστε ξανά.', - 'setting_up_db' => 'Γίνεται ρύθμιση της βάσης δεδομένων σας ...', - 'user_created' => 'Λογαριασμός χρήστη δημιουργήθηκε!', - 'failed_to_create' => 'Το PHP Censor απέτυχε να δημιουργήσει το λογαριασμό διαχειριστή σας.', - 'config_exists' => 'Το αρχείο ρυθμίσεων PHP Censor υπάρχει και δεν είναι άδειο.', - 'update_instead' => 'Εάν προσπαθούσατε να ενημερώσετε PHP Censor, παρακαλούμε χρησιμοποιήστε καλύτερα το php-censor:update αντ \'αυτού.', - // Update 'update_app' => 'Ενημέρωστε την βάση δεδομένων ώστε να αντικατοπτρίζει τροποποιημένα μοντέλα.', 'updating_app' => 'Γίνεται ενημέρωση της βάσης δεδομένων PHP Censor:', diff --git a/src/PHPCensor/Languages/lang.en.php b/src/PHPCensor/Languages/lang.en.php index b4051200..75c0dc4d 100644 --- a/src/PHPCensor/Languages/lang.en.php +++ b/src/PHPCensor/Languages/lang.en.php @@ -337,43 +337,6 @@ PHP Censor', 'started' => 'Started', 'finished' => 'Finished', - // Installer - 'installation_url' => 'PHP Censor Installation URL', - 'db_host' => 'Database Host', - 'db_name' => 'Database Name', - 'db_user' => 'Database Username', - 'db_pass' => 'Database Password', - 'admin_name' => 'Admin Name', - 'admin_pass' => 'Admin Password', - 'admin_email' => 'Admin Email Address', - 'config_path' => 'Config File Path', - 'install_app' => 'Install PHP Censor', - 'welcome_to_app' => 'Welcome to PHP Censor', - 'please_answer' => 'Please answer the following questions:', - 'app_php_req' => 'PHP Censor requires at least PHP 5.4.0 to function.', - 'extension_required' => 'Extension required: %s', - 'function_required' => 'PHP Censor needs to be able to call the %s() function. Is it disabled in php.ini?', - 'requirements_not_met' => 'PHP Censor cannot be installed, as not all requirements are met. - Please review the errors above before continuing.', - 'must_be_valid_email' => 'Must be a valid email address.', - 'must_be_valid_url' => 'Must be a valid URL.', - 'enter_name' => 'Admin Name: ', - 'enter_email' => 'Admin Email: ', - 'enter_password' => 'Admin Password: ', - 'enter_app_url' => 'Your PHP Censor URL ("http://php-censor.local" for example): ', - - 'enter_db_host' => 'Please enter your DB host [localhost]: ', - 'enter_db_port' => 'Please enter your DB port [3306]: ', - 'enter_db_name' => 'Please enter your DB database name [php-censor-db]: ', - 'enter_db_user' => 'Please enter your DB username [php-censor-user]: ', - 'enter_db_pass' => 'Please enter your DB password: ', - 'could_not_connect' => 'PHP Censor could not connect to DB with the details provided. Please try again.', - 'setting_up_db' => 'Setting up your database... ', - 'user_created' => 'User account created!', - 'failed_to_create' => 'PHP Censor failed to create your admin account.', - 'config_exists' => 'The PHP Censor config file exists and is not empty.', - 'update_instead' => 'If you were trying to update PHP Censor, please use php-censor:update instead.', - // Update 'update_app' => 'Update the database to reflect modified models.', 'updating_app' => 'Updating PHP Censor database: ', diff --git a/src/PHPCensor/Languages/lang.es.php b/src/PHPCensor/Languages/lang.es.php index d496ca41..12802823 100644 --- a/src/PHPCensor/Languages/lang.es.php +++ b/src/PHPCensor/Languages/lang.es.php @@ -281,42 +281,6 @@ PHP Censor', 'search_packagist_for_more' => 'Buscar más paquetes en Packagist', 'search' => 'Buscar »', - // Installer - 'installation_url' => 'URL de la instalación PHP Censor', - 'db_host' => 'Host', - 'db_name' => 'Nombre de la base de datos', - 'db_user' => 'Usuario de la base de datos', - 'db_pass' => 'Clave de la base de datos', - 'admin_name' => 'Nombre del Admin', - 'admin_pass' => 'Clave del Admin', - 'admin_email' => 'Email de Admin', - 'config_path' => 'Ruta al archivo config', - 'install_app' => 'Instalar PHP Censor', - 'welcome_to_app' => 'Bienvenido a PHP Censor', - 'please_answer' => 'Por favor, responde las siguientes preguntas:', - 'app_php_req' => 'PHP Censor requiere al menos PHP 5.4.0 para funcionar.', - 'extension_required' => 'Extensión requerida: %s', - 'function_required' => 'PHP Censor debe poder invocar la función %s(). Está deshabilitada en php.ini?', - 'requirements_not_met' => 'PHP Censor no pudo ser instalado, ya que no se cumplen todos los requerimientos. - Por favor, corrige los errores antes de continuar.', - 'must_be_valid_email' => 'Debe ser una dirección de correos válida.', - 'must_be_valid_url' => 'Debe ser una URL válida.', - 'enter_name' => 'Nombre del Admin:', - 'enter_email' => 'Email del Admin:', - 'enter_password' => 'Contraseña de Admin:', - 'enter_app_url' => 'La URL de PHP Censor ("Por ejemplo: http://php-censor.local"): ', - - 'enter_db_host' => 'Por favor, ingresa el servidor DB [localhost]: ', - 'enter_db_name' => 'Por favor, ingresa el nombre de la base de datos DB [php-censor-db]: ', - 'enter_db_user' => 'Por favor, ingresa el usuario DB [php-censor-user]: ', - 'enter_db_pass' => 'Por favor, ingresa la contraseña DB: ', - 'could_not_connect' => 'PHP Censor no pudo conectarse a DB con los datos dados. Por favor, intenta nuevamente.', - 'setting_up_db' => 'Configurando base de datos... ', - 'user_created' => '¡Cuenta de usuario creada!', - 'failed_to_create' => 'PHP Censor no pudo crear la cuenta de admin.', - 'config_exists' => 'El archivo config de PHP Censor ya existe y no es vacío.', - 'update_instead' => 'Si está intentando actualizar PHP Censor, por favor, utiliza php-censor:update.', - // Update 'update_app' => 'Actuliza la base de datos para reflejar los modelos actualizados.', 'updating_app' => 'Actualizando base de datos PHP Censor: ', diff --git a/src/PHPCensor/Languages/lang.fr.php b/src/PHPCensor/Languages/lang.fr.php index 5da55271..a7268140 100644 --- a/src/PHPCensor/Languages/lang.fr.php +++ b/src/PHPCensor/Languages/lang.fr.php @@ -301,42 +301,6 @@ PHP Censor', 'stage_success' => 'Succes', 'stage_failure' => 'Échec', - // Installer - 'installation_url' => 'URL d\'installation de PHP Censor', - 'db_host' => 'Hôte de la BDD', - 'db_name' => 'Nom de la BDD', - 'db_user' => 'Nom d\'utilisateur de la BDD', - 'db_pass' => 'Mot de passe de la BDD', - 'admin_name' => 'Nom de l\'admin', - 'admin_pass' => 'Mot de passe admin', - 'admin_email' => 'Adresse email de l\'admin', - 'config_path' => 'Chemin vers le fichier de configuration', - 'install_app' => 'Installer PHP Censor', - 'welcome_to_app' => 'Bienvenue sur PHP Censor', - 'please_answer' => 'Merci de répondre aux questions suivantes :', - 'app_php_req' => 'PHP Censor requiert au moins PHP 5.4.0 pour fonctionner.', - 'extension_required' => 'Extensions requises : %s', - 'function_required' => 'PHP Censor doit être capable d\'appeler la fonction %s(). Est-ce qu\'elle est désactivée dans votre php.ini?', - 'requirements_not_met' => 'PHP Censor ne peut pas être installé parce que toutes les conditions requises ne sont pas respectées. - Merci de corriger les erreurs ci-dessus avant de continuer.', - 'must_be_valid_email' => 'Doit être une adresse email valide.', - 'must_be_valid_url' => 'Doit être une URL valide.', - 'enter_name' => 'Nom de l\'admin: ', - 'enter_email' => 'Email de l\'admin: ', - 'enter_password' => 'Mot de passe de l\'admin: ', - 'enter_app_url' => 'Votre URL vers PHP Censor (par exemple "http://php-censor.local"): ', - - 'enter_db_host' => 'Merci d\'entrer le nom d\'hôte DB [localhost]: ', - 'enter_db_name' => 'Merci d\'entrer le nom de la base DB [php-censor-db]: ', - 'enter_db_user' => 'Merci d\'entrer le nom d\'utilisateur DB [php-censor-user]: ', - 'enter_db_pass' => 'Merci d\'entrer le mot de passe DB: ', - 'could_not_connect' => 'PHP Censor ne peut pas se connecter à DB à partir des informations fournies. Veuillez réessayer..', - 'setting_up_db' => 'Paramétrage de la base de données... ', - 'user_created' => 'Le compte utilisateur a été créé !', - 'failed_to_create' => 'PHP Censor n\'a pas réussi à créer votre compte admin.', - 'config_exists' => 'Le fichier de configuration PHP Censor existe et n\'est pas vide.', - 'update_instead' => 'Si vous essayez de mettre à jour PHP Censor, merci d\'utiliser la commande php-censor:update.', - // Update 'update_app' => 'Mise à jour de la base de données pour refléter les modifications apportées aux modèles.', 'updating_app' => 'Mise à jour de la base de données PHP Censor : ', diff --git a/src/PHPCensor/Languages/lang.it.php b/src/PHPCensor/Languages/lang.it.php index e7142c3d..f095cc9f 100644 --- a/src/PHPCensor/Languages/lang.it.php +++ b/src/PHPCensor/Languages/lang.it.php @@ -286,43 +286,6 @@ PHP Censor', 'search_packagist_for_more' => 'Cerca altri pacchetti su Packagist', 'search' => 'Cerca »', - // Installer - 'installation_url' => 'URL di installazione di PHP Censor', - 'db_host' => 'Host del Database', - 'db_name' => 'Nome del Database', - 'db_user' => 'Username del Database', - 'db_pass' => 'Password del Database', - 'admin_name' => 'Nome dell\'amministratore', - 'admin_pass' => 'Password dell\'amministratore', - 'admin_email' => 'Email dell\'amministratore', - 'config_path' => 'Percorso del file di configurazione', - 'install_app' => 'Installa PHP Censor', - 'welcome_to_app' => 'Benvenuto in PHP Censor', - 'please_answer' => 'Per favore rispondi alle seguenti domande:', - 'app_php_req' => 'PHP Censor richiede come minimo PHP 5.4.0 per funzionare.', - 'extension_required' => 'Le estensioni richieste sono: %s', - 'function_required' => 'PHP Censor richiede di poter chiamare la funzione %s(). Questa funzionalità è disabibiltata nel - php.ini?', - 'requirements_not_met' => 'PHP Censor non può essere installato, non tutti i requisiti sono soddisfatti. - Per favore controlla gli errori riportati prima di proseguire.', - 'must_be_valid_email' => 'Deve essere un indirizzo email valido.', - 'must_be_valid_url' => 'Deve essere un URL valido.', - 'enter_name' => 'Nome dell\'amministratore: ', - 'enter_email' => 'Email dell\'amministratore: ', - 'enter_password' => 'Password dell\'amministratore: ', - 'enter_app_url' => 'L\'URL di PHP Censor ("http://php-censor.locale" ad esempio): ', - - 'enter_db_host' => 'Per favore inserisci l\'host DB [localhost]: ', - 'enter_db_name' => 'Per favore inserisci il nome DB [php-censor-db]: ', - 'enter_db_user' => 'Per favore inserisci l\'username DB [php-censor-user]: ', - 'enter_db_pass' => 'Per favore inserisci la password DB: ', - 'could_not_connect' => 'PHP Censor non può connettersi a DB con le informazioni fornite. Per favore prova ancora.', - 'setting_up_db' => 'Configurzione del tuo database... ', - 'user_created' => 'Account utente creato!', - 'failed_to_create' => 'PHP Censor non è riuscito a creare il tuo account amministrativo.', - 'config_exists' => 'Il file di configurazione di PHP Censor esiste e non è vuoto.', - 'update_instead' => 'Se stai cercando di aggiornare PHP Censor, per favore usa php-censor:update.', - // Update 'update_app' => 'Aggiorna il database per riflettere le modifiche ai model.', 'updating_app' => 'Aggiornamenti del database di PHP Censor: ', diff --git a/src/PHPCensor/Languages/lang.nl.php b/src/PHPCensor/Languages/lang.nl.php index 7c326a32..4120a582 100644 --- a/src/PHPCensor/Languages/lang.nl.php +++ b/src/PHPCensor/Languages/lang.nl.php @@ -286,42 +286,6 @@ keer je composer update uitvoert.', 'search_packagist_for_more' => 'Doorzoek Packagist naar meer packages', 'search' => 'Zoek »', - // Installer - 'installation_url' => 'PHP Censor installatie URL', - 'db_host' => 'Database host', - 'db_name' => 'Database naam', - 'db_user' => 'Database gebruikersnaam', - 'db_pass' => 'Database wachtwoord', - 'admin_name' => 'Administrator naam', - 'admin_pass' => 'Administrator wachtwoord', - 'admin_email' => 'Administrator e-mailadres', - 'config_path' => 'Pad naar configuratiebestand', - 'install_app' => 'Installeer PHP Censor', - 'welcome_to_app' => 'Welkom bij PHP Censor', - 'please_answer' => 'Gelieve onderstaande vragen te beantwoorden:', - 'app_php_req' => 'PHP Censor heeft ten minste PHP 5.4.0 nodig om te werken.', - 'extension_required' => 'Extensie benodigd: %s', - 'function_required' => 'PHP Censor moet functie %s() kunnen aanroepen. Is deze uitgeschakeld in php.ini?', - 'requirements_not_met' => 'PHP Censor kan niet worden geïnstalleerd omdat niet aan alle vereisten is voldaan. -Gelieve de fouten na te kijken vooraleer verder te gaan.', - 'must_be_valid_email' => 'Moet een geldig e-mailadres zijn.', - 'must_be_valid_url' => 'Moet een geldige URL zijn.', - 'enter_name' => 'Administrator naam: ', - 'enter_email' => 'Administrator e-mailadres: ', - 'enter_password' => 'Administrator wachtwoord: ', - 'enter_app_url' => 'Je PHP Censor URL (bijvoorbeeld "http://php-censor.local"): ', - - 'enter_db_host' => 'Vul je DB host in [localhost]: ', - 'enter_db_name' => 'Vul je DB databasenaam in [php-censor-db]: ', - 'enter_db_user' => 'Vul je DB gebruikersnaam in [php-censor-user]: ', - 'enter_db_pass' => 'Vul je DB watchtwoord in: ', - 'could_not_connect' => 'PHP Censor kon met deze gegevens geen verbinding maken met DB. Gelieve opnieuw te proberen.', - 'setting_up_db' => 'Database wordt aangemaakt...', - 'user_created' => 'Gebruikersprofiel aangemaakt!', - 'failed_to_create' => 'PHP Censor kon je administratorprofiel niet aanmaken.', - 'config_exists' => 'Het PHP Censor configuratiebestand bestaat en is niet leeg.', - 'update_instead' => 'Liever php-censor:update te gebruiken indien je PHP Censor probeerde te updaten, ', - // Update 'update_app' => 'Update de database naar het beeld van gewijzigde modellen.', 'updating_app' => 'PHP Censor database wordt geüpdatet:', diff --git a/src/PHPCensor/Languages/lang.pl.php b/src/PHPCensor/Languages/lang.pl.php index 3de94599..67818533 100644 --- a/src/PHPCensor/Languages/lang.pl.php +++ b/src/PHPCensor/Languages/lang.pl.php @@ -287,42 +287,6 @@ wywołaniu polecenia composer update.', 'search_packagist_for_more' => 'Przeszukaj Packagist po więcej pakietów', 'search' => 'Szukaj »', - // Installer - 'installation_url' => 'URL instalacyjny PHP Censor', - 'db_host' => 'Host Bazy Danych', - 'db_name' => 'Nazwa Bazy Danych', - 'db_user' => 'Nazwa Użytkownika Bazy Danych', - 'db_pass' => 'Hasło Bazy Danych', - 'admin_name' => 'Imię Admina', - 'admin_pass' => 'Hasło Admina', - 'admin_email' => 'Adres Email Admina', - 'config_path' => 'Ścieżka Pliku Config', - 'install_app' => 'Zainstaluj PHP Censor', - 'welcome_to_app' => 'Witaj w PHP Censor', - 'please_answer' => 'Odpowiedz na poniższe pytania:', - 'app_php_req' => 'PHP Censor wymaga przynajmniej PHP 5.4.0 do prawidłowego funkcjonowania.', - 'extension_required' => 'Wymagane rozszerzenie: %s', - 'function_required' => 'PHP Censor musi mieć możliwość wywołania funkcji %s(). Czy ona jest wyłączona w php.ini?', - 'requirements_not_met' => 'Nie można zainstalować PHP Censor, ponieważ nie wszystkie wymagania zostały spełnione. -Przejrzyj powyższą listę błędów przed kontynuowaniem.', - 'must_be_valid_email' => 'Poprawny adres email jest wymagany.', - 'must_be_valid_url' => 'Poprawny URL jest wymagany.', - 'enter_name' => 'Imię Admina: ', - 'enter_email' => 'Email Admina: ', - 'enter_password' => 'Hasło Admina: ', - 'enter_app_url' => 'URL PHP Censor (na przykład "http://php-censor.local"): ', - - 'enter_db_host' => 'Wpisz hosta DB [host lokalny]: ', - 'enter_db_name' => 'Wpisz nazwę bazy danych DB [php-censor-db]: ', - 'enter_db_user' => 'Wpisz nazwę użytkownika DB [php-censor-user]: ', - 'enter_db_pass' => 'Wpisz hasło DB: ', - 'could_not_connect' => 'Z podanymi ustawieniami PHP Censor nie udało się połączyć z DB. Spróbuj ponownie.', - 'setting_up_db' => 'Ustawianie Twojej bazy danych...', - 'user_created' => 'Utworzono konto użytkownika!', - 'failed_to_create' => 'PHP Censor nie udało się założyc Twojego konta administratora.', - 'config_exists' => 'Plik konfiguracji PHP Censor istnieje i nie jest pusty.', - 'update_instead' => 'Jeśli próbowałeś zaktualizować PHP Censor, użyj php-censor:update.', - // Update 'update_app' => 'Zaktualizuj bazę danych zgodnie ze zmodyfikowanymi modelami.', 'updating_app' => 'Aktualizacja bazy danych PHP Censor:', diff --git a/src/PHPCensor/Languages/lang.pt-br.php b/src/PHPCensor/Languages/lang.pt-br.php index 0606c350..4c5feba4 100644 --- a/src/PHPCensor/Languages/lang.pt-br.php +++ b/src/PHPCensor/Languages/lang.pt-br.php @@ -308,42 +308,6 @@ PHP Censor', 'stage_broken' => 'Broken', 'stage_fixed' => 'Fixed', - // Installer - 'installation_url' => 'PHP Censor Installation URL', - 'db_host' => 'Database Host', - 'db_name' => 'Database Name', - 'db_user' => 'Database Username', - 'db_pass' => 'Database Password', - 'admin_name' => 'Admin Name', - 'admin_pass' => 'Admin Password', - 'admin_email' => 'Admin Email Address', - 'config_path' => 'Config File Path', - 'install_app' => 'Install PHP Censor', - 'welcome_to_app' => 'Welcome to PHP Censor', - 'please_answer' => 'Please answer the following questions:', - 'app_php_req' => 'PHP Censor requires at least PHP 5.3.8 to function.', - 'extension_required' => 'Extension required: %s', - 'function_required' => 'PHP Censor needs to be able to call the %s() function. Is it disabled in php.ini?', - 'requirements_not_met' => 'PHP Censor cannot be installed, as not all requirements are met. - Please review the errors above before continuing.', - 'must_be_valid_email' => 'Must be a valid email address.', - 'must_be_valid_url' => 'Must be a valid URL.', - 'enter_name' => 'Admin Name: ', - 'enter_email' => 'Admin Email: ', - 'enter_password' => 'Admin Password: ', - 'enter_app_url' => 'Your PHP Censor URL ("http://php-censor.local" for example): ', - - 'enter_db_host' => 'Please enter your DB host [localhost]: ', - 'enter_db_name' => 'Please enter your DB database name [php-censor-db]: ', - 'enter_db_user' => 'Please enter your DB username [php-censor-user]: ', - 'enter_db_pass' => 'Please enter your DB password: ', - 'could_not_connect' => 'PHP Censor could not connect to DB with the details provided. Please try again.', - 'setting_up_db' => 'Setting up your database... ', - 'user_created' => 'User account created!', - 'failed_to_create' => 'PHP Censor failed to create your admin account.', - 'config_exists' => 'The PHP Censor config file exists and is not empty.', - 'update_instead' => 'If you were trying to update PHP Censor, please use php-censor:update instead.', - // Update 'update_app' => 'Update the database to reflect modified models.', 'updating_app' => 'Updating PHP Censor database: ', diff --git a/src/PHPCensor/Languages/lang.ru.php b/src/PHPCensor/Languages/lang.ru.php index eed19ca3..bf877611 100644 --- a/src/PHPCensor/Languages/lang.ru.php +++ b/src/PHPCensor/Languages/lang.ru.php @@ -326,43 +326,6 @@ PHP Censor', 'started' => 'Началась', 'finished' => 'Закончилась', - // Installer - 'installation_url' => 'URL-адрес PHP Censor для установки', - 'db_host' => 'Хост базы данных', - 'db_name' => 'Имя базы данных', - 'db_user' => 'Пользователь базы данных', - 'db_pass' => 'Пароль базы данных', - 'admin_name' => 'Имя администратора', - 'admin_pass' => 'Пароль администратора', - 'admin_email' => 'Email администратора', - 'config_path' => 'Путь до файла конфигурации', - 'install_app' => 'Установить PHP Censor', - 'welcome_to_app' => 'Добро пожаловать в PHP Censor', - 'please_answer' => 'Пожалуйста, ответьте на несколько вопросов:', - 'app_php_req' => 'PHP Censor необходима для работы версия PHP не ниже 5.4.0.', - 'extension_required' => 'Требуется расширение PHP: %s', - 'function_required' => 'PHP Censor необходима возможность вызывать %s() функцию. Она выключена в php.ini?', - 'requirements_not_met' => 'PHP Censor не может быть установлен, пока не все требования выполнены. - Пожалуйста, просмотрите возникшие ошибки перед тем, как продолжить.', - 'must_be_valid_email' => 'Должен быть корректным email-адресом.', - 'must_be_valid_url' => 'Должен быть корректным URL-адресом.', - 'enter_name' => 'Имя администратора: ', - 'enter_email' => 'Email администратора: ', - 'enter_password' => 'Пароль администратора: ', - 'enter_app_url' => 'URL-адрес вашего PHP Censor (например: "http://php-censor.local"): ', - - 'enter_db_host' => 'Пожалуйста, введите хост DB [localhost]: ', - 'enter_db_port' => 'Пожалуйста, введите порт DB [3306]: ', - 'enter_db_name' => 'Пожалуйста, введите имя базы данных DB [php-censor-db]: ', - 'enter_db_user' => 'Пожалуйста, введите пользователя DB [php-censor-user]: ', - 'enter_db_pass' => 'Пожалуйста, введите пароль DB: ', - 'could_not_connect' => 'PHP Censor не может подключится к DB с переданными параметрами. Пожалуйста, попробуйте еще раз.', - 'setting_up_db' => 'Установка базы данных... ', - 'user_created' => 'Аккаунт пользователя создан!', - 'failed_to_create' => 'PHP Censor не удалось создать аккаунт администратора.', - 'config_exists' => 'Файл конфигурации PHP Censor уже существует, и он не пустой.', - 'update_instead' => 'Если вы собираетесь обновить PHP Censor, пожалуйста, используйте команду php-censor:update.', - // Update 'update_app' => 'Обновите базу данных с учетом обновленных моделей.', 'updating_app' => 'Обновление базы данных PHP Censor: ', diff --git a/src/PHPCensor/Languages/lang.uk.php b/src/PHPCensor/Languages/lang.uk.php index 8f2450aa..2036c7ce 100644 --- a/src/PHPCensor/Languages/lang.uk.php +++ b/src/PHPCensor/Languages/lang.uk.php @@ -286,42 +286,6 @@ PHP Censor', 'search_packagist_for_more' => 'Знайти більше пакетів на Packagist', 'search' => 'Знайти »', - // Installer - 'installation_url' => 'URL встановлення PHP Censor', - 'db_host' => 'Хост бази даних', - 'db_name' => 'Назва бази даних', - 'db_user' => 'Ім’я користувача бази даних', - 'db_pass' => 'Пароль бази даних', - 'admin_name' => 'Ім’я адміністратора', - 'admin_pass' => 'Пароль адміністратора', - 'admin_email' => 'Email адреса адміністратора', - 'config_path' => 'Шлях до файла конфігурації', - 'install_app' => 'Встановити PHP Censor', - 'welcome_to_app' => 'Ласкаво просимо до PHP Censor', - 'please_answer' => 'Будь ласка, дайте відповідь на наступні питання:', - 'app_php_req' => 'PHP Censor вимагає для роботи, принаймні, версію PHP 5.4.0.', - 'extension_required' => 'Необхідне розширення: %s', - 'function_required' => 'PHP Censor необхідна можливість викликати функцію %s(). Вона відключена у php.ini?', - 'requirements_not_met' => 'Неможливо встановити PHP Censor, оскільки не всі вимоги виконані. -Будь ласка, продивіться наявні помилки перед тим, як продовжити.', - 'must_be_valid_email' => 'Повинно бути коректною email адресою.', - 'must_be_valid_url' => 'Повинно бути коректним URL.', - 'enter_name' => 'Ім’я адміністратора: ', - 'enter_email' => 'Email адміністратора: ', - 'enter_password' => 'Пароль адміністратора: ', - 'enter_app_url' => 'URL адреса вашого PHP Censor (наприклад, "http://php-censor.local"): ', - - 'enter_db_host' => 'Будь ласка, введіть хост DB [localhost]: ', - 'enter_db_name' => 'Будь ласка, введить ім’я бази даних DB [php-censor-db]: ', - 'enter_db_user' => 'Будь ласка, введить ім’я користувача DB [php-censor-user]: ', - 'enter_db_pass' => 'Будь ласка, введить ваш пароль DB: ', - 'could_not_connect' => 'PHP Censor не може підключитися до DB із наданими параметрами. Будь ласка, спробуйте ще раз.', - 'setting_up_db' => 'Налаштування вашої бази даних...', - 'user_created' => 'Аккаунт користувача створено!', - 'failed_to_create' => 'PHP Censor не вдалося створити ваш аккаунт адміністратора.', - 'config_exists' => 'Файл конфігурації PHP Censor вже існує та не є порожнім.', - 'update_instead' => 'Якщо ви збираєтесь оновити PHP Censor, будь ласка, використовуйте команду php-censor:update.', - // Update 'update_app' => 'Оновити базу даних для відображення змінених моделей.', 'updating_app' => 'Оновлення бази даних PHP Censor:', diff --git a/src/PHPCensor/Languages/lang.zh.php b/src/PHPCensor/Languages/lang.zh.php index 34d964fc..2cddaf35 100644 --- a/src/PHPCensor/Languages/lang.zh.php +++ b/src/PHPCensor/Languages/lang.zh.php @@ -301,42 +301,6 @@ PHP Censor', 'stage_broken' => 'Broken', 'stage_fixed' => 'Fixed', - // Installer - 'installation_url' => 'PHP Censor Installation URL', - 'db_host' => 'Database Host', - 'db_name' => 'Database Name', - 'db_user' => 'Database Username', - 'db_pass' => 'Database Password', - 'admin_name' => 'Admin Name', - 'admin_pass' => 'Admin Password', - 'admin_email' => 'Admin Email Address', - 'config_path' => 'Config File Path', - 'install_app' => 'Install PHP Censor', - 'welcome_to_app' => 'Welcome to PHP Censor', - 'please_answer' => 'Please answer the following questions:', - 'app_php_req' => 'PHP Censor requires at least PHP 5.3.8 to function.', - 'extension_required' => 'Extension required: %s', - 'function_required' => 'PHP Censor needs to be able to call the %s() function. Is it disabled in php.ini?', - 'requirements_not_met' => 'PHP Censor cannot be installed, as not all requirements are met. - Please review the errors above before continuing.', - 'must_be_valid_email' => 'Must be a valid email address.', - 'must_be_valid_url' => 'Must be a valid URL.', - 'enter_name' => 'Admin Name: ', - 'enter_email' => 'Admin Email: ', - 'enter_password' => 'Admin Password: ', - 'enter_app_url' => 'Your PHP Censor URL ("http://php-censor.local" for example): ', - - 'enter_db_host' => 'Please enter your DB host [localhost]: ', - 'enter_db_name' => 'Please enter your DB database name [php-censor-db]: ', - 'enter_db_user' => 'Please enter your DB username [php-censor-user]: ', - 'enter_db_pass' => 'Please enter your DB password: ', - 'could_not_connect' => 'PHP Censor could not connect to DB with the details provided. Please try again.', - 'setting_up_db' => 'Setting up your database... ', - 'user_created' => 'User account created!', - 'failed_to_create' => 'PHP Censor failed to create your admin account.', - 'config_exists' => 'The PHP Censor config file exists and is not empty.', - 'update_instead' => 'If you were trying to update PHP Censor, please use php-censor:update instead.', - // Update 'update_app' => 'Update the database to reflect modified models.', 'updating_app' => 'Updating PHP Censor database: ', diff --git a/tests/PHPCensor/Command/InstallCommandTest.php b/tests/PHPCensor/Command/InstallCommandTest.php index fa56408a..3e77af18 100644 --- a/tests/PHPCensor/Command/InstallCommandTest.php +++ b/tests/PHPCensor/Command/InstallCommandTest.php @@ -1,13 +1,5 @@ '3306', '--db-name' => 'php-censor-db', '--db-user' => 'php-censor-user', - '--db-pass' => 'php-censor-password', + '--db-password' => 'php-censor-password', '--db-type' => 'mysql', - '--admin-mail' => 'admin@php-censor.local', + '--admin-email' => 'admin@php-censor.local', '--admin-name' => 'admin', - '--admin-pass' => 'admin-password', + '--admin-password' => 'admin-password', '--url' => 'http://php-censor.local', '--queue-use' => null, ]; @@ -125,7 +118,7 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase // Get tester and execute with extracted parameters. $commandTester = $this->getCommandTester($dialog); - $parameters = $this->getConfig($param); + $parameters = $this->getConfig($param); $commandTester->execute($parameters); } @@ -183,7 +176,7 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase $dialog->expects($this->once())->method('ask')->willReturn('testedvalue'); - $this->executeWithoutParam('--db-pass', $dialog); + $this->executeWithoutParam('--db-password', $dialog); // Check that specified arguments are correctly loaded. $this->assertEquals('testedvalue', $this->config['b8']['database']['password']); @@ -209,10 +202,10 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase // We specified an input value for hostname. $dialog->expects($this->once())->method('ask')->willReturn('admin@php-censor.local'); - $this->executeWithoutParam('--admin-mail', $dialog); + $this->executeWithoutParam('--admin-email', $dialog); // Check that specified arguments are correctly loaded. - $this->assertEquals('admin@php-censor.local', $this->admin['mail']); + $this->assertEquals('admin@php-censor.local', $this->admin['email']); } public function testAdminNameConfig() @@ -235,9 +228,9 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase // We specified an input value for hostname. $dialog->expects($this->once())->method('ask')->willReturn('testedvalue'); - $this->executeWithoutParam('--admin-pass', $dialog); + $this->executeWithoutParam('--admin-password', $dialog); // Check that specified arguments are correctly loaded. - $this->assertEquals('testedvalue', $this->admin['pass']); + $this->assertEquals('testedvalue', $this->admin['password']); } } From 0ab4acd72f591f27e10106a9227c5edd1458298d Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Sun, 5 Feb 2017 00:44:55 +0700 Subject: [PATCH 08/13] Fixes for authentication and users --- src/PHPCensor/Command/CreateAdminCommand.php | 2 +- src/PHPCensor/Command/InstallCommand.php | 2 +- src/PHPCensor/Controller/UserController.php | 8 ++-- .../Authentication/UserProvider/Ldap.php | 7 +++- src/PHPCensor/Service/UserService.php | 41 ++++--------------- tests/PHPCensor/Service/UserServiceTest.php | 19 ++++++++- 6 files changed, 36 insertions(+), 43 deletions(-) diff --git a/src/PHPCensor/Command/CreateAdminCommand.php b/src/PHPCensor/Command/CreateAdminCommand.php index 6d661f89..779b9fc6 100644 --- a/src/PHPCensor/Command/CreateAdminCommand.php +++ b/src/PHPCensor/Command/CreateAdminCommand.php @@ -81,7 +81,7 @@ class CreateAdminCommand extends Command $adminPass = $helper->ask($input, $output, $question); try { - $userService->createUser($adminName, $adminEmail, $adminPass, true); + $userService->createUser($adminName, $adminEmail, 'default', json_encode(['type' => 'internal']), $adminPass, true); $output->writeln('User account created!'); } catch (\Exception $e) { $output->writeln(sprintf('%s', 'PHP Censor failed to create your admin account.')); diff --git a/src/PHPCensor/Command/InstallCommand.php b/src/PHPCensor/Command/InstallCommand.php index fe8f0ae8..ef99a127 100644 --- a/src/PHPCensor/Command/InstallCommand.php +++ b/src/PHPCensor/Command/InstallCommand.php @@ -466,7 +466,7 @@ class InstallCommand extends Command /** @var UserStore $userStore */ $userStore = Factory::getStore('User'); $userService = new UserService($userStore); - $userService->createUser($admin['name'], $admin['email'], $admin['password'], 1); + $userService->createUser($admin['name'], $admin['email'], 'default', json_encode(['type' => 'internal']), $admin['password'], true); $output->writeln('User account created!'); } catch (\Exception $ex) { diff --git a/src/PHPCensor/Controller/UserController.php b/src/PHPCensor/Controller/UserController.php index 67b619dd..afbd324e 100644 --- a/src/PHPCensor/Controller/UserController.php +++ b/src/PHPCensor/Controller/UserController.php @@ -175,12 +175,12 @@ class UserController extends Controller } - $name = $this->getParam('name', null); - $email = $this->getParam('email', null); + $name = $this->getParam('name', null); + $email = $this->getParam('email', null); $password = $this->getParam('password', null); - $isAdmin = (int)$this->getParam('is_admin', 0); + $isAdmin = (int)$this->getParam('is_admin', 0); - $this->userService->createUser($name, $email, $password, $isAdmin); + $this->userService->createUser($name, $email, 'default', json_encode(['type' => 'internal']), $password, $isAdmin); $response = new b8\Http\Response\RedirectResponse(); $response->setHeader('Location', APP_URL . 'user'); diff --git a/src/PHPCensor/Security/Authentication/UserProvider/Ldap.php b/src/PHPCensor/Security/Authentication/UserProvider/Ldap.php index 142da14f..46593475 100644 --- a/src/PHPCensor/Security/Authentication/UserProvider/Ldap.php +++ b/src/PHPCensor/Security/Authentication/UserProvider/Ldap.php @@ -14,6 +14,7 @@ use b8\Store\Factory; use PHPCensor\Model\User; use PHPCensor\Security\Authentication\LoginPasswordProviderInterface; use PHPCensor\Service\UserService; +use PHPCensor\Store\UserStore; /** * Ldap user provider. @@ -68,11 +69,13 @@ class Ldap extends AbstractProvider implements LoginPasswordProviderInterface public function provisionUser($identifier) { - $userService = new UserService(Factory::getStore('User')); + /** @var UserStore $user */ + $user = Factory::getStore('User'); + $userService = new UserService($user); $parts = explode("@", $identifier); $username = $parts[0]; - return $userService->createUserWithProvider($username, $identifier, $this->key, null); + return $userService->createUser($username, $identifier, $this->key, json_encode($this->config), '', false); } } diff --git a/src/PHPCensor/Service/UserService.php b/src/PHPCensor/Service/UserService.php index dfddda6d..c7860aca 100644 --- a/src/PHPCensor/Service/UserService.php +++ b/src/PHPCensor/Service/UserService.php @@ -35,46 +35,21 @@ class UserService /** * Create a new user within PHPCI. * - * @param string $name - * @param string $emailAddress - * @param string $password - * @param bool $isAdmin - * @param string $language - * @param integer $perPage + * @param string $name + * @param string $email + * @param string $providerKey + * @param string $providerData + * @param string $password + * @param bool $isAdmin * * @return User */ - public function createUser($name, $emailAddress, $password, $isAdmin = false, $language = null, $perPage = null) + public function createUser($name, $email, $providerKey, $providerData, $password, $isAdmin = false) { $user = new User(); $user->setName($name); - $user->setEmail($emailAddress); + $user->setEmail($email); $user->setHash(password_hash($password, PASSWORD_DEFAULT)); - $user->setIsAdmin(($isAdmin ? 1 : 0)); - $user->setLanguage($language); - $user->setPerPage($perPage); - - return $this->store->save($user); - } - - /** - * Create a new user within PHPCI (with provider). - * - * @param $name - * @param $emailAddress - * @param $providerKey - * @param $providerData - * @param bool $isAdmin - * - * @return \PHPCI\Model\User - */ - - public function createUserWithProvider($name, $emailAddress, $providerKey, $providerData, $isAdmin = false) - { - $user = new User(); - $user->setName($name); - $user->setEmail($emailAddress); - $user->setHash(""); $user->setProviderKey($providerKey); $user->setProviderData($providerData); $user->setIsAdmin(($isAdmin ? 1 : 0)); diff --git a/tests/PHPCensor/Service/UserServiceTest.php b/tests/PHPCensor/Service/UserServiceTest.php index 6e18e2db..fdfe0241 100644 --- a/tests/PHPCensor/Service/UserServiceTest.php +++ b/tests/PHPCensor/Service/UserServiceTest.php @@ -42,7 +42,14 @@ class UserServiceTest extends \PHPUnit_Framework_TestCase public function testExecute_CreateNonAdminUser() { - $user = $this->testedService->createUser('Test', 'test@example.com', 'testing', 0); + $user = $this->testedService->createUser( + 'Test', + 'test@example.com', + 'default', + json_encode(['type' => 'internal']), + 'testing', + false + ); $this->assertEquals('Test', $user->getName()); $this->assertEquals('test@example.com', $user->getEmail()); @@ -52,7 +59,15 @@ class UserServiceTest extends \PHPUnit_Framework_TestCase public function testExecute_CreateAdminUser() { - $user = $this->testedService->createUser('Test', 'test@example.com', 'testing', 1); + $user = $this->testedService->createUser( + 'Test', + 'test@example.com', + 'default', + json_encode(['type' => 'internal']), + 'testing', + true + ); + $this->assertEquals(1, $user->getIsAdmin()); } From ed532bad7d84da03e0eb9366f28113ce2f031e9b Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Sun, 5 Feb 2017 11:18:33 +0700 Subject: [PATCH 09/13] Commands fixes --- src/PHPCensor/Command/CreateAdminCommand.php | 14 +----- src/PHPCensor/Command/CreateBuildCommand.php | 24 +++-------- src/PHPCensor/Command/InstallCommand.php | 12 +++--- src/PHPCensor/Command/PollCommand.php | 28 ++++-------- src/PHPCensor/Command/RebuildCommand.php | 12 +----- src/PHPCensor/Command/RebuildQueueCommand.php | 15 +------ src/PHPCensor/Command/RunCommand.php | 26 ++++------- src/PHPCensor/Command/WorkerCommand.php | 12 +----- src/PHPCensor/Console/Application.php | 42 ++++++++++-------- src/PHPCensor/Languages/lang.da.php | 27 ------------ src/PHPCensor/Languages/lang.de.php | 27 ------------ src/PHPCensor/Languages/lang.el.php | 27 ------------ src/PHPCensor/Languages/lang.en.php | 25 ----------- src/PHPCensor/Languages/lang.es.php | 21 --------- src/PHPCensor/Languages/lang.fr.php | 27 ------------ src/PHPCensor/Languages/lang.it.php | 27 ------------ src/PHPCensor/Languages/lang.nl.php | 27 ------------ src/PHPCensor/Languages/lang.pl.php | 27 ------------ src/PHPCensor/Languages/lang.pt-br.php | 30 ------------- src/PHPCensor/Languages/lang.ru.php | 27 ------------ src/PHPCensor/Languages/lang.uk.php | 27 ------------ src/PHPCensor/Languages/lang.zh.php | 30 ------------- .../PHPCensor/Command/InstallCommandTest.php | 43 ++++++++++++++++++- tests/bootstrap.php | 2 - 24 files changed, 100 insertions(+), 479 deletions(-) diff --git a/src/PHPCensor/Command/CreateAdminCommand.php b/src/PHPCensor/Command/CreateAdminCommand.php index 779b9fc6..e64389b1 100644 --- a/src/PHPCensor/Command/CreateAdminCommand.php +++ b/src/PHPCensor/Command/CreateAdminCommand.php @@ -1,16 +1,8 @@ setName('php-censor:create-admin') - ->setDescription(Lang::get('create_admin_user')); + ->setDescription('Create an admin user'); } /** diff --git a/src/PHPCensor/Command/CreateBuildCommand.php b/src/PHPCensor/Command/CreateBuildCommand.php index a49d30c0..7c15c759 100644 --- a/src/PHPCensor/Command/CreateBuildCommand.php +++ b/src/PHPCensor/Command/CreateBuildCommand.php @@ -1,15 +1,7 @@ setName('php-censor:create-build') - ->setDescription(Lang::get('create_build_project')) - ->addArgument('projectId', InputArgument::REQUIRED, Lang::get('project_id_argument')) - ->addOption('commit', null, InputOption::VALUE_OPTIONAL, Lang::get('commit_id_option')) - ->addOption('branch', null, InputOption::VALUE_OPTIONAL, Lang::get('branch_name_option')); + ->setDescription('Create a build for a project') + ->addArgument('projectId', InputArgument::REQUIRED, 'A project ID') + ->addOption('commit', null, InputOption::VALUE_OPTIONAL, 'Commit ID to build') + ->addOption('branch', null, InputOption::VALUE_OPTIONAL, 'Branch to build'); } /** @@ -78,9 +68,9 @@ class CreateBuildCommand extends Command try { $this->buildService->createBuild($project, $commitId, $branch); - $output->writeln(Lang::get('build_created')); + $output->writeln('Build Created'); } catch (\Exception $e) { - $output->writeln(sprintf('%s', Lang::get('failed'))); + $output->writeln('Failed'); $output->writeln(sprintf('%s', $e->getMessage())); } } diff --git a/src/PHPCensor/Command/InstallCommand.php b/src/PHPCensor/Command/InstallCommand.php index ef99a127..0ddca876 100644 --- a/src/PHPCensor/Command/InstallCommand.php +++ b/src/PHPCensor/Command/InstallCommand.php @@ -82,10 +82,9 @@ class InstallCommand extends Command } $output->writeln(''); - $conf = []; + $conf = []; $conf['b8']['database'] = $db; - - $conf['php-censor'] = $this->getConfigInformation($input, $output); + $conf['php-censor'] = $this->getConfigInformation($input, $output); $this->writeConfigFile($conf); $this->setupDatabase($output); @@ -375,8 +374,9 @@ class InstallCommand extends Command ] ]; + $dbPort = (integer)$dbPort; if ($dbPort) { - $dbServers[0]['port'] = (integer)$dbPort; + $dbServers[0]['port'] = $dbPort; } $db['servers']['read'] = $dbServers; @@ -402,8 +402,8 @@ class InstallCommand extends Command { try { $dns = $db['type'] . ':host=' . $db['servers']['write'][0]['host']; - if (isset($db['servers']['write'][0]['host'])) { - $dns .= ';port=' . (integer)$db['servers']['write'][0]['host']; + if (isset($db['servers']['write'][0]['port'])) { + $dns .= ';port=' . (integer)$db['servers']['write'][0]['port']; } $dns .= ';dbname=' . $db['name']; diff --git a/src/PHPCensor/Command/PollCommand.php b/src/PHPCensor/Command/PollCommand.php index 8c43a637..6901369c 100644 --- a/src/PHPCensor/Command/PollCommand.php +++ b/src/PHPCensor/Command/PollCommand.php @@ -1,18 +1,10 @@ - * @package PHPCI - * @subpackage Console + * @author Jimmy Cleuren */ class PollCommand extends Command { @@ -43,7 +33,7 @@ class PollCommand extends Command { $this ->setName('php-censor:poll-github') - ->setDescription(Lang::get('poll_github')); + ->setDescription('Poll GitHub to check if we need to start a build.'); } /** @@ -58,16 +48,16 @@ class PollCommand extends Command $token = $this->settings['php-censor']['github']['token']; if (!$token) { - $this->logger->error(Lang::get('no_token')); + $this->logger->error('No GitHub token found'); return; } $buildStore = Factory::getStore('Build'); - $this->logger->addInfo(Lang::get('finding_projects')); + $this->logger->addInfo('Finding projects to poll'); $projectStore = Factory::getStore('Project'); $result = $projectStore->getWhere(); - $this->logger->addInfo(Lang::get('found_n_projects', count($result['items']))); + $this->logger->addInfo(sprintf('Found %d projects', count($result['items']))); foreach ($result['items'] as $project) { $http = new HttpClient('https://api.github.com'); @@ -77,12 +67,10 @@ class PollCommand extends Command $last_committer = $commits['body'][0]['commit']['committer']['email']; $message = $commits['body'][0]['commit']['message']; - $this->logger->info(Lang::get('last_commit_is', $project->getTitle(), $last_commit)); + $this->logger->info(sprintf('Last commit to GitHub for %s is %s', $project->getTitle(), $last_commit)); if (!$project->getArchived() && ($project->getLastCommit() != $last_commit && $last_commit != "")) { - $this->logger->info( - Lang::get('adding_new_build') - ); + $this->logger->info('Last commit is different to database, adding new build.'); $build = new Build(); $build->setProjectId($project->getId()); @@ -102,6 +90,6 @@ class PollCommand extends Command } } - $this->logger->addInfo(Lang::get('finished_processing_builds')); + $this->logger->addInfo('Finished processing builds.'); } } diff --git a/src/PHPCensor/Command/RebuildCommand.php b/src/PHPCensor/Command/RebuildCommand.php index f3e06174..5a8f7445 100644 --- a/src/PHPCensor/Command/RebuildCommand.php +++ b/src/PHPCensor/Command/RebuildCommand.php @@ -1,13 +1,5 @@ - * @package PHPCI - * @subpackage Console + * @author Dan Cryer */ class RebuildCommand extends Command { diff --git a/src/PHPCensor/Command/RebuildQueueCommand.php b/src/PHPCensor/Command/RebuildQueueCommand.php index 942f1565..47837021 100644 --- a/src/PHPCensor/Command/RebuildQueueCommand.php +++ b/src/PHPCensor/Command/RebuildQueueCommand.php @@ -1,29 +1,18 @@ - * @package PHPCI - * @subpackage Console + * @author Dan Cryer */ class RebuildQueueCommand extends Command { @@ -69,7 +58,7 @@ class RebuildQueueCommand extends Command $store = Factory::getStore('Build'); $result = $store->getByStatus(0); - $this->logger->addInfo(Lang::get('found_n_builds', count($result['items']))); + $this->logger->addInfo(sprintf('Found %d builds', count($result['items']))); $buildService = new BuildService($store); diff --git a/src/PHPCensor/Command/RunCommand.php b/src/PHPCensor/Command/RunCommand.php index 1ee84316..5a6a566b 100644 --- a/src/PHPCensor/Command/RunCommand.php +++ b/src/PHPCensor/Command/RunCommand.php @@ -1,17 +1,9 @@ - * @package PHPCI - * @subpackage Console + * @author Dan Cryer */ class RunCommand extends Command { @@ -62,8 +52,8 @@ class RunCommand extends Command { $this ->setName('php-censor:run-builds') - ->setDescription(Lang::get('run_all_pending')) - ->addOption('debug', null, null, 'Run PHP Censor in Debug Mode'); + ->setDescription('Run all pending PHP Censor builds') + ->addOption('debug', null, null, 'Run PHP Censor in debug mode'); } /** @@ -90,13 +80,13 @@ class RunCommand extends Command $running = $this->validateRunningBuilds(); $this->logger->pushProcessor(new LoggedBuildContextTidier()); - $this->logger->addInfo(Lang::get('finding_builds')); + $this->logger->addInfo('Finding builds to process'); /** @var BuildStore $store */ $store = Factory::getStore('Build'); $result = $store->getByStatus(Build::STATUS_PENDING, $this->maxBuilds); - $this->logger->addInfo(Lang::get('found_n_builds', count($result['items']))); + $this->logger->addInfo(sprintf('Found %d builds', count($result['items']))); $builds = 0; @@ -106,7 +96,7 @@ class RunCommand extends Command // Skip build (for now) if there's already a build running in that project: if (in_array($build->getProjectId(), $running)) { - $this->logger->addInfo(Lang::get('skipping_build', $build->getId())); + $this->logger->addInfo(sprintf('Skipping Build %d - Project build already in progress.', $build->getId())); $result['items'][] = $build; // Re-run build validator: @@ -137,7 +127,7 @@ class RunCommand extends Command } - $this->logger->addInfo(Lang::get('finished_processing_builds')); + $this->logger->addInfo('Finished processing builds.'); return $builds; } @@ -164,7 +154,7 @@ class RunCommand extends Command $start = $build->getStarted()->getTimestamp(); if (($now - $start) > $timeout) { - $this->logger->addInfo(Lang::get('marked_as_failed', $build->getId())); + $this->logger->addInfo(sprintf('Build %d marked as failed due to timeout.', $build->getId())); $build->setStatus(Build::STATUS_FAILED); $build->setFinished(new \DateTime()); $store->save($build); diff --git a/src/PHPCensor/Command/WorkerCommand.php b/src/PHPCensor/Command/WorkerCommand.php index a211d63e..2946b542 100644 --- a/src/PHPCensor/Command/WorkerCommand.php +++ b/src/PHPCensor/Command/WorkerCommand.php @@ -1,11 +1,4 @@ - * @package PHPCI - * @subpackage Console + * @author Dan Cryer */ class WorkerCommand extends Command { diff --git a/src/PHPCensor/Console/Application.php b/src/PHPCensor/Console/Application.php index 70fd52c7..c405fda0 100644 --- a/src/PHPCensor/Console/Application.php +++ b/src/PHPCensor/Console/Application.php @@ -34,33 +34,37 @@ class Application extends BaseApplication /** * Constructor. * - * @param string $name The name of the application - * @param string $version The version of the application - * @param LoggerConfig $loggerConfig Logger config + * @param string $name The name of the application + * @param string $version The version of the application */ - public function __construct($name = 'PHP Censor - Continuous Integration for PHP', $version = '', LoggerConfig $loggerConfig = null) + public function __construct($name = 'PHP Censor - Continuous Integration for PHP', $version = '') { parent::__construct($name, $version); + $loggerConfig = LoggerConfig::newFromFile(APP_DIR . 'loggerconfig.php'); + $applicationConfig = Config::getInstance(); $databaseSettings = $applicationConfig->get('b8.database', []); - $phinxSettings = [ - 'paths' => [ - 'migrations' => 'src/PHPCensor/Migrations', - ], - 'environments' => [ - 'default_migration_table' => 'migration', - 'default_database' => 'php-censor', - 'php-censor' => [ - 'adapter' => $databaseSettings['type'], - 'host' => $databaseSettings['servers']['write'][0]['host'], - 'name' => $databaseSettings['name'], - 'user' => $databaseSettings['username'], - 'pass' => $databaseSettings['password'], + $phinxSettings = []; + if ($databaseSettings) { + $phinxSettings = [ + 'paths' => [ + 'migrations' => 'src/PHPCensor/Migrations', ], - ], - ]; + 'environments' => [ + 'default_migration_table' => 'migration', + 'default_database' => 'php-censor', + 'php-censor' => [ + 'adapter' => $databaseSettings['type'], + 'host' => $databaseSettings['servers']['write'][0]['host'], + 'name' => $databaseSettings['name'], + 'user' => $databaseSettings['username'], + 'pass' => $databaseSettings['password'], + ], + ], + ]; + } if (!empty($databaseSettings['port'])) { $phinxSettings['environments']['php-censor']['port'] = (integer)$databaseSettings['port']; diff --git a/src/PHPCensor/Languages/lang.da.php b/src/PHPCensor/Languages/lang.da.php index 4878bc5f..3741db89 100644 --- a/src/PHPCensor/Languages/lang.da.php +++ b/src/PHPCensor/Languages/lang.da.php @@ -198,7 +198,6 @@ Services sektionen under dit Bitbucket-repository.', 'result' => 'Resultat', 'ok' => 'OK', 'took_n_seconds' => 'Tog %d sekunder', - 'build_created' => 'Build Oprettet', 'build_started' => 'Build Startet', 'build_finished' => 'Build Afsluttet', 'test_message' => 'Message', @@ -290,32 +289,6 @@ du kører composer update.', 'not_installed' => 'PHP Censor lader til ikke at være installeret.', 'install_instead' => 'Installér venligst PHP Censor via php-censor:install istedet.', - // Poll Command - 'poll_github' => 'Check via GitHub om et build skal startes.', - 'no_token' => 'GitHub-token findes ikke', - 'finding_projects' => 'Finder projekter der kan forespørges', - 'found_n_projects' => '%d projekter fundet', - 'last_commit_is' => 'Sidste commit til GitHub for %s er %s', - 'adding_new_build' => 'Sidste commit er forskellig fra databasen, tilføjer nyt build.', - 'finished_processing_builds' => 'Kørsel af builds afsluttet.', - - // Create Admin - 'create_admin_user' => 'Tilføj en administrator', - 'incorrect_format' => 'Forkert format', - - // Create Build Command - 'create_build_project' => 'Create a build for a project', - 'project_id_argument' => 'A project ID', - 'commit_id_option' => 'Commit ID to build', - 'branch_name_option' => 'Branch to build', - - // Run Command - 'run_all_pending' => 'Kør alle PHP Censor builds i køen.', - 'finding_builds' => 'Finder builds der skal køres', - 'found_n_builds' => '%d builds fundet', - 'skipping_build' => 'Springer over Build %d - projektet kører et build lige nu.', - 'marked_as_failed' => 'Build %d blev markeret som fejlet pga. timeout.', - // Builder 'missing_app_yml' => 'Dette projekt har ingen .php-censor.yml (.phpci.yml|phpci.yml) fil, eller filen er tom.', 'build_success' => 'BUILD SUCCES', diff --git a/src/PHPCensor/Languages/lang.de.php b/src/PHPCensor/Languages/lang.de.php index 880ff6b8..49099c7c 100644 --- a/src/PHPCensor/Languages/lang.de.php +++ b/src/PHPCensor/Languages/lang.de.php @@ -208,7 +208,6 @@ generiert. Um es zu verwenden, fügen Sie einfach den folgenden Public Key im Ab 'result' => 'Resultat', 'ok' => 'OK', 'took_n_seconds' => 'Benötigte %d Sekunden', - 'build_created' => 'Build erstellt', 'build_started' => 'Build gestartet', 'build_finished' => 'Build abgeschlossen', 'test_message' => 'Nachricht', @@ -313,32 +312,6 @@ generiert. Um es zu verwenden, fügen Sie einfach den folgenden Public Key im Ab 'not_installed' => 'PHP Censor scheint nicht installiert zu sein.', 'install_instead' => 'Bitte installieren Sie PHP Censor stattdessen via php-censor:install.', - // Poll Command - 'poll_github' => 'GitHub abfragen, um herauszufinden, ob ein Build gestartet werden muss.', - 'no_token' => 'Kein GitHub-Token gefunden', - 'finding_projects' => 'Suche Projekte, um diese abzufragen', - 'found_n_projects' => '%d Projekte gefunden', - 'last_commit_is' => 'Der letzte Commit zu GitHub für %s ist %s', - 'adding_new_build' => 'Letzter Commit unterscheidet sich von der Datenbank, füge neuen Build hinzu.', - 'finished_processing_builds' => 'Bearbeiten der Builds abgeschlossen.', - - // Create Admin - 'create_admin_user' => 'Administratorenbenutzer erstellen', - 'incorrect_format' => 'Falsches Format', - - // Create Build Command - 'create_build_project' => 'Create a build for a project', - 'project_id_argument' => 'A project ID', - 'commit_id_option' => 'Commit ID to build', - 'branch_name_option' => 'Branch to build', - - // Run Command - 'run_all_pending' => 'Führe alle ausstehenden PHP Censor Builds aus.', - 'finding_builds' => 'Suche verarbeitbare Builds', - 'found_n_builds' => '%d Builds gefunden', - 'skipping_build' => 'Überspringe Build %d - Es wird bereits ein Build auf diesem Projekt ausgeführt.', - 'marked_as_failed' => 'Build %d wegen Zeitüberschreitung als fehlgeschlagen markiert.', - // Builder 'missing_app_yml' => 'Dieses Projekt beinhaltet keine .php-censor.yml (.phpci.yml|phpci.yml)-Datei, oder sie ist leer.', 'build_success' => 'BUILD ERFOLGREICH', diff --git a/src/PHPCensor/Languages/lang.el.php b/src/PHPCensor/Languages/lang.el.php index eb11f985..cdf55580 100644 --- a/src/PHPCensor/Languages/lang.el.php +++ b/src/PHPCensor/Languages/lang.el.php @@ -199,7 +199,6 @@ Services του Bitbucket αποθετηρίου σας.', 'result' => 'Αποτέλεσμα', 'ok' => 'ΟΚ', 'took_n_seconds' => 'Χρειάστηκαν %d δευτερόλεπτα', - 'build_created' => 'Η κατασκευή δημιουργήθηκε', 'build_started' => 'Η κατασκευή άρχισε', 'build_finished' => 'Η κατασκευή ολοκληρώθηκε', 'test_message' => 'Message', @@ -292,32 +291,6 @@ Services του Bitbucket αποθετηρίου σας.', 'not_installed' => 'Το PHP Censor δεν φένεται να είναι εγκατεστημένο', 'install_instead' => 'Παρακαλούμε εγκαταστήστε το PHP Censor καλύτερα με το php-censor:install αντ \'αυτού.', - // Poll Command - 'poll_github' => 'Δημοσκόπηση στο GitHub για να ελέγξετε αν θα πρέπει να ξεκινήσει μια κατασκευή.', - 'no_token' => 'Δεν βρέθηκε GitHub token', - 'finding_projects' => 'Αναζήτηση έργων για δημοσκόπηση', - 'found_n_projects' => 'Βρέθηκαν %d έργα', - 'last_commit_is' => 'H τελευταία συνεισφορά στο GitHub για %s είναι %s', - 'adding_new_build' => 'Τελευταία συνεισφορά είναι διαφορετική από τη βάση δεδομένων, γίνεται προσθήκη νέας κατασκευής.', - 'finished_processing_builds' => 'Ολοκληρώθηκε η επεξεργασία κατασκευής.', - - // Create Admin - 'create_admin_user' => 'Δημιουργήστε ένα χρήστη διαχειριστή', - 'incorrect_format' => 'Λανθασμένη μορφοποίηση', - - // Create Build Command - 'create_build_project' => 'Create a build for a project', - 'project_id_argument' => 'A project ID', - 'commit_id_option' => 'Commit ID to build', - 'branch_name_option' => 'Branch to build', - - // Run Command - 'run_all_pending' => 'Εκτελέστε όλες τις εκκρεμείς PHP Censor κατασκευές.', - 'finding_builds' => 'Αναζήτηση κατασκευών για επεξεργασία', - 'found_n_builds' => 'Βρέθηκαν %d κατασκευές', - 'skipping_build' => 'Παράκαμψη κατασκευής %d - Η διαδικασία κατασκευής του έργου βρίσκεται ήδη σε εξέλιξη.', - 'marked_as_failed' => 'Η κατασκεύη %d επισημάνθηκε ως αποτυχημένη λόγω χρονικού ορίου', - // Builder 'missing_app_yml' => 'Το έργο δεν περιέχει το αρχείο .php-censor.yml (.phpci.yml|phpci.yml) ή είναι άδειο.', 'build_success' => 'ΚΑΤΑΣΚΕΥΗ ΕΠΙΤΥΧΗΣ', diff --git a/src/PHPCensor/Languages/lang.en.php b/src/PHPCensor/Languages/lang.en.php index 75c0dc4d..37cb878a 100644 --- a/src/PHPCensor/Languages/lang.en.php +++ b/src/PHPCensor/Languages/lang.en.php @@ -227,7 +227,6 @@ PHP Censor', 'result' => 'Result', 'ok' => 'OK', 'took_n_seconds' => 'Took %d seconds', - 'build_created' => 'Build Created', 'build_started' => 'Build Started', 'build_finished' => 'Build Finished', 'test_message' => 'Message', @@ -343,35 +342,11 @@ PHP Censor', 'not_installed' => 'PHP Censor does not appear to be installed.', 'install_instead' => 'Please install PHP Censor via php-censor:install instead.', - // Poll Command - 'poll_github' => 'Poll GitHub to check if we need to start a build.', - 'no_token' => 'No GitHub token found', - 'finding_projects' => 'Finding projects to poll', - 'found_n_projects' => 'Found %d projects', - 'last_commit_is' => 'Last commit to GitHub for %s is %s', - 'adding_new_build' => 'Last commit is different to database, adding new build.', - 'finished_processing_builds' => 'Finished processing builds.', - - // Create Admin - 'create_admin_user' => 'Create an admin user', - 'incorrect_format' => 'Incorrect format', - // Create Build Command - 'create_build_project' => 'Create a build for a project', - 'project_id_argument' => 'A project ID', - 'commit_id_option' => 'Commit ID to build', - 'branch_name_option' => 'Branch to build', 'add_to_queue_failed' => 'Build created successfully, but failed to add to build queue. This usually happens when PHP Censor is set to use a beanstalkd server that does not exist, or your beanstalkd server has stopped.', - // Run Command - 'run_all_pending' => 'Run all pending PHP Censor builds.', - 'finding_builds' => 'Finding builds to process', - 'found_n_builds' => 'Found %d builds', - 'skipping_build' => 'Skipping Build %d - Project build already in progress.', - 'marked_as_failed' => 'Build %d marked as failed due to timeout.', - // Builder 'missing_app_yml' => 'This project does not contain a .php-censor.yml (.phpci.yml|phpci.yml) file, or it is empty.', 'build_success' => 'BUILD SUCCESS', diff --git a/src/PHPCensor/Languages/lang.es.php b/src/PHPCensor/Languages/lang.es.php index 12802823..c5824c0a 100644 --- a/src/PHPCensor/Languages/lang.es.php +++ b/src/PHPCensor/Languages/lang.es.php @@ -203,7 +203,6 @@ PHP Censor', 'result' => 'Resultado', 'ok' => 'OK', 'took_n_seconds' => 'Tomó %d segundos', - 'build_created' => 'Build Creado', 'build_started' => 'Build Comenzado', 'build_finished' => 'Build Terminado', @@ -287,26 +286,6 @@ PHP Censor', 'not_installed' => 'PHP Censor no está instalado.', 'install_instead' => 'Por favor, instala PHP Censor via php-censor:install.', - // Poll Command - 'poll_github' => 'Chequear en GitHub si se necesita comenzar un Build.', - 'no_token' => 'No se encontró ningún token GitHub', - 'finding_projects' => 'Buscando proyectos para chequear', - 'found_n_projects' => 'Se encontraron %d proyectos', - 'last_commit_is' => 'El último commit en GitHub para %s es %s', - 'adding_new_build' => 'Último commit es diferente a la base de datos, agregando nuevo build.', - 'finished_processing_builds' => 'Fin de procesamiento de builds.', - - // Create Admin - 'create_admin_user' => 'Crear un usuario Admin', - 'incorrect_format' => 'Formato incorrecto', - - // Run Command - 'run_all_pending' => 'Ejecutar todos los builds PHP Censor pendientes.', - 'finding_builds' => 'Buscando builds a procesar', - 'found_n_builds' => 'Se encontraron %d builds', - 'skipping_build' => 'Saltando Build %d - Build del proyecto ya en ejecución.', - 'marked_as_failed' => 'Build %d falló debido a timeout.', - // Builder 'missing_app_yml' => 'Este proyecto no contiene el archivo .php-censor.yml (.phpci.yml|phpci.yml) o está vacío.', 'build_success' => 'BUILD EXITOSO', diff --git a/src/PHPCensor/Languages/lang.fr.php b/src/PHPCensor/Languages/lang.fr.php index a7268140..feb4e15a 100644 --- a/src/PHPCensor/Languages/lang.fr.php +++ b/src/PHPCensor/Languages/lang.fr.php @@ -203,7 +203,6 @@ PHP Censor', 'result' => 'Resultat', 'ok' => 'OK', 'took_n_seconds' => 'Exécuté en %d secondes', - 'build_created' => 'Build créé', 'build_started' => 'Build démarré', 'build_finished' => 'Build terminé', 'test_message' => 'Message', @@ -307,32 +306,6 @@ PHP Censor', 'not_installed' => 'PHP Censor n\'a pas l\'air d\'être installé.', 'install_instead' => 'Merci d\'installer PHP Censor grâce à la commande php-censor:install.', - // Poll Command - 'poll_github' => 'Demander à GitHub de vérifier si nous devons démarrer un build.', - 'no_token' => 'Aucun token GitHub n\'a été trouvé', - 'finding_projects' => 'Recherche des projets à sonder', - 'found_n_projects' => '%d projets trouvés', - 'last_commit_is' => 'Le dernier commit sur GitHub pour %s est %s', - 'adding_new_build' => 'Le dernier commit est différent de celui présent en base de données, ajout d\'un nouveau build.', - 'finished_processing_builds' => 'Traitement des builds terminé.', - - // Create Admin - 'create_admin_user' => 'Créer un utilisateur admin', - 'incorrect_format' => 'Format incorrect', - - // Create Build Command - 'create_build_project' => 'Créer un build projet', - 'project_id_argument' => 'ID du projet', - 'commit_id_option' => 'ID du commit', - 'branch_name_option' => 'Branche', - - // Run Command - 'run_all_pending' => 'Démarrage de tout les builds PHP Censor en attente.', - 'finding_builds' => 'Découverte des builds à traiter', - 'found_n_builds' => '%d builds trouvés', - 'skipping_build' => 'Saut du build %d - Un build sur le projet est déjà en cours.', - 'marked_as_failed' => 'Le build %d a été marqué échoué à cause d\'un timeout.', - // Builder 'missing_app_yml' => 'Ce projet ne contient pas de fichier .php-censor.yml (.phpci.yml|phpci.yml), ou il est vide.', 'build_success' => 'BUILD RÉUSSI', diff --git a/src/PHPCensor/Languages/lang.it.php b/src/PHPCensor/Languages/lang.it.php index f095cc9f..34b0a065 100644 --- a/src/PHPCensor/Languages/lang.it.php +++ b/src/PHPCensor/Languages/lang.it.php @@ -200,7 +200,6 @@ PHP Censor', 'result' => 'Risultati', 'ok' => 'OK', 'took_n_seconds' => 'Sono stati impiegati %d seconds', - 'build_created' => 'Build Creata', 'build_started' => 'Build Avviata', 'build_finished' => 'Build Terminata', 'test_message' => 'Message', @@ -292,32 +291,6 @@ PHP Censor', 'not_installed' => 'PHP Censor sembra non essere installato.', 'install_instead' => 'Per favore installa PHP Censor tramite php-censor:install.', - // Poll Command - 'poll_github' => 'Richiesta a GitHub per verificare se è necessario avviare una build.', - 'no_token' => 'Nessuno token per GitHub trovato', - 'finding_projects' => 'Ricerca dei progetti da aggiornare', - 'found_n_projects' => 'Trovati %d progetti', - 'last_commit_is' => 'Ultimo commit su GitHub per %s è %s', - 'adding_new_build' => 'L\'ultimo commit è diverso da quello registrato, new build aggiunta.', - 'finished_processing_builds' => 'Terminato di processare le build.', - - // Create Admin - 'create_admin_user' => 'Crea un nuovo utente amministrarore', - 'incorrect_format' => 'Formato errato', - - // Create Build Command - 'create_build_project' => 'Create a build for a project', - 'project_id_argument' => 'A project ID', - 'commit_id_option' => 'Commit ID to build', - 'branch_name_option' => 'Branch to build', - - // Run Command - 'run_all_pending' => 'Esegui tutte le build in attesa su PHP Censor.', - 'finding_builds' => 'Ricerca delel build da processare', - 'found_n_builds' => 'Trovate %d build', - 'skipping_build' => 'Saltata la build %d - La build del progetto è già in corso.', - 'marked_as_failed' => 'Build %d è stata contrassegnata come fallita per un timeout.', - // Builder 'missing_app_yml' => 'Questo progetto non contiene il file .php-censor.yml (.phpci.yml|phpci.yml), o il file è vuoto.', 'build_success' => 'BUILD PASSATA', diff --git a/src/PHPCensor/Languages/lang.nl.php b/src/PHPCensor/Languages/lang.nl.php index 4120a582..c21743be 100644 --- a/src/PHPCensor/Languages/lang.nl.php +++ b/src/PHPCensor/Languages/lang.nl.php @@ -199,7 +199,6 @@ Services sectie van je Bitbucket repository toegevoegd worden.', 'result' => 'Resultaat', 'ok' => 'OK', 'took_n_seconds' => 'Duurde %d seconden', - 'build_created' => 'Build aangemaakt', 'build_started' => 'Build gestart', 'build_finished' => 'Build beëindigd', 'test_message' => 'Message', @@ -292,32 +291,6 @@ keer je composer update uitvoert.', 'not_installed' => 'PHP Censor lijkt niet geïnstalleerd te zijn.', 'install_instead' => 'Gelieve PHP Censor via php-censor:install te installeren.', - // Poll Command - 'poll_github' => 'Poll GitHub om te controleren of we een build moeten starten.', - 'no_token' => 'Geen GitHub token gevonden', - 'finding_projects' => 'Vind projecten om te pollen', - 'found_n_projects' => '%d projecten gevonden', - 'last_commit_is' => 'Laatste commit naar GitHub voor %s is %s', - 'adding_new_build' => 'Laatste commit verschilt van database, nieuwe build wordt toegevoegd', - 'finished_processing_builds' => 'Verwerking builds voltooid.', - - // Create Admin - 'create_admin_user' => 'Administrator-gebruiker aanmaken', - 'incorrect_format' => 'Incorrect formaat', - - // Create Build Command - 'create_build_project' => 'Create a build for a project', - 'project_id_argument' => 'A project ID', - 'commit_id_option' => 'Commit ID to build', - 'branch_name_option' => 'Branch to build', - - // Run Command - 'run_all_pending' => 'Voer alle wachtende PHP Censor builds uit.', - 'finding_builds' => 'Zoekt builds om te verwerken', - 'found_n_builds' => '%d builds gevonden', - 'skipping_build' => 'Build %d overslaan - Project build reeds aan de gang.', - 'marked_as_failed' => 'Build %d gemarkeerd als falende door timeout.', - // Builder 'missing_app_yml' => 'Dit project bevat geen .php-censor.yml (.phpci.yml|phpci.yml) bestand, of het is leeg.', 'build_success' => 'BUILD SUCCES', diff --git a/src/PHPCensor/Languages/lang.pl.php b/src/PHPCensor/Languages/lang.pl.php index 67818533..081b9a08 100644 --- a/src/PHPCensor/Languages/lang.pl.php +++ b/src/PHPCensor/Languages/lang.pl.php @@ -202,7 +202,6 @@ Services repozytoria Bitbucket.', 'result' => 'Wynik', 'ok' => 'OK', 'took_n_seconds' => 'Zajęło %d sekund', - 'build_created' => 'Budowanie Stworzone', 'build_started' => 'Budowanie Rozpoczęte', 'build_finished' => 'Budowanie Zakończone', 'test_message' => 'Wiadomość', @@ -293,32 +292,6 @@ wywołaniu polecenia composer update.', 'not_installed' => 'Wygląda na to, że PHP Censor nie jest zainstalowane.', 'install_instead' => 'Proszę zainstalować PHP Censor poprzez php-censor:install', - // Poll Command - 'poll_github' => 'Odpytuj GitHub, aby sprawdzić czy należy uruchomić budowę.', - 'no_token' => 'Nie znaleziono tokena GitHub', - 'finding_projects' => 'Szukanie projektów do odpytywania', - 'found_n_projects' => 'Znaleziono %d projektów', - 'last_commit_is' => 'Ostatni commit do GitHuba dla %s to %s', - 'adding_new_build' => 'Ostatni commit jest inny w bazie danych, dodaję nową budowę.', - 'finished_processing_builds' => 'Ukończono przetwarzanie budów.', - - // Create Admin - 'create_admin_user' => 'Utwórz admina', - 'incorrect_format' => 'Niepoprawny format', - - // Create Build Command - 'create_build_project' => 'Utwórz budowanie dla projektu', - 'project_id_argument' => 'ID projektu', - 'commit_id_option' => 'ID Commita do budowania', - 'branch_name_option' => 'Gałąź do budowania', - - // Run Command - 'run_all_pending' => 'Uruchom wszystkie oczekujące budowy w PHP Censor', - 'finding_builds' => 'Szukam budów do przetwarzania.', - 'found_n_builds' => 'Znaleziono %d budowań', - 'skipping_build' => 'Budowanie %d jest pomijane - Budowanie projektu jest już w toku', - 'marked_as_failed' => 'Budowanie %d nie powiodło się z powodu przekroczenia limitu czasu.', - // Builder 'missing_app_yml' => 'Projekt nie zawiera pliku .php-censor.yml (.phpci.yml|phpci.yml) lub projekt jest pusty.', 'build_success' => 'BUDOWANIE ZAKOŃCZONE SUKCESEM', diff --git a/src/PHPCensor/Languages/lang.pt-br.php b/src/PHPCensor/Languages/lang.pt-br.php index 4c5feba4..5d1e6b20 100644 --- a/src/PHPCensor/Languages/lang.pt-br.php +++ b/src/PHPCensor/Languages/lang.pt-br.php @@ -208,7 +208,6 @@ PHP Censor', 'result' => 'Result', 'ok' => 'OK', 'took_n_seconds' => 'Took %d seconds', - 'build_created' => 'Build Created', 'build_started' => 'Build Started', 'build_finished' => 'Build Finished', 'test_message' => 'Message', @@ -314,35 +313,6 @@ PHP Censor', 'not_installed' => 'PHP Censor does not appear to be installed.', 'install_instead' => 'Please install PHP Censor via php-censor:install instead.', - // Poll Command - 'poll_github' => 'Poll GitHub to check if we need to start a build.', - 'no_token' => 'No GitHub token found', - 'finding_projects' => 'Finding projects to poll', - 'found_n_projects' => 'Found %d projects', - 'last_commit_is' => 'Last commit to GitHub for %s is %s', - 'adding_new_build' => 'Last commit is different to database, adding new build.', - 'finished_processing_builds' => 'Finished processing builds.', - - // Create Admin - 'create_admin_user' => 'Create an admin user', - 'incorrect_format' => 'Incorrect format', - - // Create Build Command - 'create_build_project' => 'Create a build for a project', - 'project_id_argument' => 'A project ID', - 'commit_id_option' => 'Commit ID to build', - 'branch_name_option' => 'Branch to build', - 'add_to_queue_failed' => 'Build created successfully, but failed to add to build queue. This usually happens - when PHP Censor is set to use a beanstalkd server that does not exist, - or your beanstalkd server has stopped.', - - // Run Command - 'run_all_pending' => 'Run all pending PHP Censor builds.', - 'finding_builds' => 'Finding builds to process', - 'found_n_builds' => 'Found %d builds', - 'skipping_build' => 'Skipping Build %d - Project build already in progress.', - 'marked_as_failed' => 'Build %d marked as failed due to timeout.', - // Builder 'missing_app_yml' => 'This project does not contain a .php-censor.yml (.phpci.yml|phpci.yml) file, or it is empty.', 'build_success' => 'BUILD SUCCESS', diff --git a/src/PHPCensor/Languages/lang.ru.php b/src/PHPCensor/Languages/lang.ru.php index bf877611..b5f63faf 100644 --- a/src/PHPCensor/Languages/lang.ru.php +++ b/src/PHPCensor/Languages/lang.ru.php @@ -218,7 +218,6 @@ PHP Censor', 'result' => 'Результат', 'ok' => 'OK', 'took_n_seconds' => 'Заняло секунд: %d', - 'build_created' => 'Сборка создана', 'build_started' => 'Сборка запущена', 'build_finished' => 'Сборка окончена', 'test_message' => 'Сообщение', @@ -332,32 +331,6 @@ PHP Censor', 'not_installed' => 'PHP Censor не может быть установлен.', 'install_instead' => 'Пожалуйста, установите PHP Censor с помощью команды php-censor:install.', - // Poll Command - 'poll_github' => 'Опрос GitHub для проверки запуска сборки.', - 'no_token' => 'GitHub токен не найден', - 'finding_projects' => 'Поиск проектов для опроса', - 'found_n_projects' => 'Найдено проектов: %d', - 'last_commit_is' => 'Последний коммит на GitHub для %s - %s', - 'adding_new_build' => 'Последний коммит имеет различия с базой данных, создана сборка.', - 'finished_processing_builds' => 'Процесс сборки завершен.', - - // Create Admin - 'create_admin_user' => 'Добавить аккаунт администратора', - 'incorrect_format' => 'Неверный формат', - - // Create Build Command - 'create_build_project' => 'Создать сборку проекта', - 'project_id_argument' => 'ID проекта', - 'commit_id_option' => 'ID коммита для сборки', - 'branch_name_option' => 'Ветка для сборки', - - // Run Command - 'run_all_pending' => 'Запустить все ожидающие PHP Censor сборки.', - 'finding_builds' => 'Поиск сборок для запуска', - 'found_n_builds' => 'Найдено сборок: %d', - 'skipping_build' => 'Сборка %d пропущена - Сборка проекта уже идет.', - 'marked_as_failed' => 'Сборка %d отмечена как неудавшаяся из-за превышения лимита времени.', - // Builder 'missing_app_yml' => 'Этот проект не содержит файла .php-censor.yml (.phpci.yml|phpci.yml), или файл пустой.', 'build_success' => 'СБОРКА УСПЕШНА', diff --git a/src/PHPCensor/Languages/lang.uk.php b/src/PHPCensor/Languages/lang.uk.php index 2036c7ce..b665e42e 100644 --- a/src/PHPCensor/Languages/lang.uk.php +++ b/src/PHPCensor/Languages/lang.uk.php @@ -199,7 +199,6 @@ PHP Censor', 'result' => 'Результат', 'ok' => 'OK', 'took_n_seconds' => 'Зайняло %d секунд', - 'build_created' => 'Збірка створена', 'build_started' => 'Збірка розпочата', 'build_finished' => 'Збірка завершена', 'test_message' => 'Message', @@ -292,32 +291,6 @@ PHP Censor', 'not_installed' => 'Неможливо встановити PHP Censor.', 'install_instead' => 'Будь ласка, встановіть PHP Censor через команду php-censor:install.', - // Poll Command - 'poll_github' => 'Зробити запит до GitHub для перевірки запуску збірки.', - 'no_token' => 'GitHub токен не знайдено', - 'finding_projects' => 'Пошук проектів для запиту', - 'found_n_projects' => 'Знайдено %d проектів', - 'last_commit_is' => 'Останній коміт на GitHub для %s - %s', - 'adding_new_build' => 'Останній коміт має відмінності із базою даних, створена нова збірка.', - 'finished_processing_builds' => 'Завершено обробку збірок.', - - // Create Admin - 'create_admin_user' => 'Створити аккаунт адміністратора', - 'incorrect_format' => 'Невірний формат', - - // Create Build Command - 'create_build_project' => 'Create a build for a project', - 'project_id_argument' => 'A project ID', - 'commit_id_option' => 'Commit ID to build', - 'branch_name_option' => 'Branch to build', - - // Run Command - 'run_all_pending' => 'Запустити всі PHP Censor збірки, які очікують.', - 'finding_builds' => 'Пошук збірок для обробки', - 'found_n_builds' => 'Знайдено %d збірок', - 'skipping_build' => 'Збірка %d пропущена - Збірка проекта вже у процесі.', - 'marked_as_failed' => 'Збірка %d відмічена як невдала через перевищення ліміту часу.', - // Builder 'missing_app_yml' => 'Цей проект не містить файл .php-censor.yml (.phpci.yml|phpci.yml) або він є порожнім.', 'build_success' => 'ЗБІРКА УСПІШНА', diff --git a/src/PHPCensor/Languages/lang.zh.php b/src/PHPCensor/Languages/lang.zh.php index 2cddaf35..caa6fcfe 100644 --- a/src/PHPCensor/Languages/lang.zh.php +++ b/src/PHPCensor/Languages/lang.zh.php @@ -206,7 +206,6 @@ PHP Censor', 'result' => 'Result', 'ok' => 'OK', 'took_n_seconds' => 'Took %d seconds', - 'build_created' => 'Build Created', 'build_started' => 'Build Started', 'build_finished' => 'Build Finished', 'test_message' => 'Message', @@ -307,35 +306,6 @@ PHP Censor', 'not_installed' => 'PHP Censor does not appear to be installed.', 'install_instead' => 'Please install PHP Censor via php-censor:install instead.', - // Poll Command - 'poll_github' => 'Poll GitHub to check if we need to start a build.', - 'no_token' => 'No GitHub token found', - 'finding_projects' => 'Finding projects to poll', - 'found_n_projects' => 'Found %d projects', - 'last_commit_is' => 'Last commit to GitHub for %s is %s', - 'adding_new_build' => 'Last commit is different to database, adding new build.', - 'finished_processing_builds' => 'Finished processing builds.', - - // Create Admin - 'create_admin_user' => 'Create an admin user', - 'incorrect_format' => 'Incorrect format', - - // Create Build Command - 'create_build_project' => 'Create a build for a project', - 'project_id_argument' => 'A project ID', - 'commit_id_option' => 'Commit ID to build', - 'branch_name_option' => 'Branch to build', - 'add_to_queue_failed' => 'Build created successfully, but failed to add to build queue. This usually happens - when PHP Censor is set to use a beanstalkd server that does not exist, - or your beanstalkd server has stopped.', - - // Run Command - 'run_all_pending' => 'Run all pending PHP Censor builds.', - 'finding_builds' => 'Finding builds to process', - 'found_n_builds' => 'Found %d builds', - 'skipping_build' => 'Skipping Build %d - Project build already in progress.', - 'marked_as_failed' => 'Build %d marked as failed due to timeout.', - // Builder 'missing_app_yml' => 'This project does not contain a .php-censor.yml (.phpci.yml|phpci.yml) file, or it is empty.', 'build_success' => 'BUILD SUCCESS', diff --git a/tests/PHPCensor/Command/InstallCommandTest.php b/tests/PHPCensor/Command/InstallCommandTest.php index 3e77af18..0e3f2a30 100644 --- a/tests/PHPCensor/Command/InstallCommandTest.php +++ b/tests/PHPCensor/Command/InstallCommandTest.php @@ -130,7 +130,20 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase $this->executeWithoutParam(null, $dialog); } - public function testDatabaseHostnameConfig() + public function testDatabaseTypeConfig() + { + $dialog = $this->getHelperMock(); + + // We specified an input value for hostname. + $dialog->expects($this->once())->method('ask')->willReturn('testedvalue'); + + $this->executeWithoutParam('--db-type', $dialog); + + // Check that specified arguments are correctly loaded. + $this->assertEquals('testedvalue', $this->config['b8']['database']['type']); + } + + public function testDatabaseHostConfig() { $dialog = $this->getHelperMock(); @@ -144,6 +157,34 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase $this->assertEquals('testedvalue', $this->config['b8']['database']['servers']['write'][0]['host']); } + public function testDatabaseStringPortConfig() + { + $dialog = $this->getHelperMock(); + + // We specified an input value for hostname. + $dialog->expects($this->once())->method('ask')->willReturn('testedvalue'); + + $this->executeWithoutParam('--db-port', $dialog); + + // Check that specified arguments are correctly loaded. + $this->assertEquals(0, $this->config['b8']['database']['servers']['read'][0]['port']); + $this->assertEquals(0, $this->config['b8']['database']['servers']['write'][0]['port']); + } + + public function testDatabasePortConfig() + { + $dialog = $this->getHelperMock(); + + // We specified an input value for hostname. + $dialog->expects($this->once())->method('ask')->willReturn('333'); + + $this->executeWithoutParam('--db-port', $dialog); + + // Check that specified arguments are correctly loaded. + $this->assertEquals(333, $this->config['b8']['database']['servers']['read'][0]['port']); + $this->assertEquals(333, $this->config['b8']['database']['servers']['write'][0]['port']); + } + public function testDatabaseNameConfig() { $dialog = $this->getHelperMock(); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index beb32935..e90c3bd5 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -7,8 +7,6 @@ * @link http://www.phptesting.org/ */ -use PHPCensor\Logging\LoggerConfig; - if (!defined('ROOT_DIR')) { define('ROOT_DIR', dirname(__DIR__) . DIRECTORY_SEPARATOR); } From a558716b6cc1a868633095de46e810af964eb45b Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Sun, 5 Feb 2017 13:13:59 +0700 Subject: [PATCH 10/13] Added installation variant with config file instead options --- src/PHPCensor/Command/InstallCommand.php | 69 ++++++++++--------- src/PHPCensor/Console/Application.php | 2 +- .../PHPCensor/Command/InstallCommandTest.php | 4 +- 3 files changed, 41 insertions(+), 34 deletions(-) diff --git a/src/PHPCensor/Command/InstallCommand.php b/src/PHPCensor/Command/InstallCommand.php index 0ddca876..afe4ff41 100644 --- a/src/PHPCensor/Command/InstallCommand.php +++ b/src/PHPCensor/Command/InstallCommand.php @@ -36,19 +36,20 @@ class InstallCommand extends Command $this ->setName('php-censor:install') - ->addOption('url', null, InputOption::VALUE_OPTIONAL, 'PHP Censor installation URL') - ->addOption('db-type', null, InputOption::VALUE_OPTIONAL, 'Database type') - ->addOption('db-host', null, InputOption::VALUE_OPTIONAL, 'Database host') - ->addOption('db-port', null, InputOption::VALUE_OPTIONAL, 'Database port') - ->addOption('db-name', null, InputOption::VALUE_OPTIONAL, 'Database name') - ->addOption('db-user', null, InputOption::VALUE_OPTIONAL, 'Database user') - ->addOption('db-password', null, InputOption::VALUE_OPTIONAL, 'Database password') - ->addOption('admin-name', null, InputOption::VALUE_OPTIONAL, 'Admin name') - ->addOption('admin-password', null, InputOption::VALUE_OPTIONAL, 'Admin password') - ->addOption('admin-email', null, InputOption::VALUE_OPTIONAL, 'Admin email') - ->addOption('queue-use', null, InputOption::VALUE_OPTIONAL, 'Don\'t ask for queue details') - ->addOption('queue-host', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue server hostname') - ->addOption('queue-name', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue name') + ->addOption('url', null, InputOption::VALUE_OPTIONAL, 'PHP Censor installation URL') + ->addOption('db-type', null, InputOption::VALUE_OPTIONAL, 'Database type') + ->addOption('db-host', null, InputOption::VALUE_OPTIONAL, 'Database host') + ->addOption('db-port', null, InputOption::VALUE_OPTIONAL, 'Database port') + ->addOption('db-name', null, InputOption::VALUE_OPTIONAL, 'Database name') + ->addOption('db-user', null, InputOption::VALUE_OPTIONAL, 'Database user') + ->addOption('db-password', null, InputOption::VALUE_OPTIONAL, 'Database password') + ->addOption('admin-name', null, InputOption::VALUE_OPTIONAL, 'Admin name') + ->addOption('admin-password', null, InputOption::VALUE_OPTIONAL, 'Admin password') + ->addOption('admin-email', null, InputOption::VALUE_OPTIONAL, 'Admin email') + ->addOption('queue-use', null, InputOption::VALUE_OPTIONAL, 'Don\'t ask for queue details') + ->addOption('queue-host', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue server hostname') + ->addOption('queue-name', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue name') + ->addOption('config-from-file', null, InputOption::VALUE_OPTIONAL, 'Take config from file and ignore options') ->setDescription('Install PHP Censor'); } @@ -58,7 +59,9 @@ class InstallCommand extends Command */ protected function execute(InputInterface $input, OutputInterface $output) { - if (!$this->verifyNotInstalled($output)) { + $configFromFile = (boolean)$input->getOption('config-from-file'); + + if (!$configFromFile && !$this->verifyNotInstalled($output)) { return; } @@ -70,23 +73,27 @@ class InstallCommand extends Command $this->checkRequirements($output); - $output->writeln(''); - $output->writeln('Please answer the following questions:'); - $output->writeln('--------------------------------------'); - $output->writeln(''); + if (!$configFromFile) { + $output->writeln(''); + $output->writeln('Please answer the following questions:'); + $output->writeln('--------------------------------------'); + $output->writeln(''); - $connectionVerified = false; - while (!$connectionVerified) { - $db = $this->getDatabaseInformation($input, $output); - $connectionVerified = $this->verifyDatabaseDetails($db, $output); + $connectionVerified = false; + while (!$connectionVerified) { + $db = $this->getDatabaseInformation($input, $output); + $connectionVerified = $this->verifyDatabaseDetails($db, $output); + } + $output->writeln(''); + + $conf = []; + $conf['b8']['database'] = $db; + $conf['php-censor'] = $this->getConfigInformation($input, $output); + + $this->writeConfigFile($conf); } - $output->writeln(''); - $conf = []; - $conf['b8']['database'] = $db; - $conf['php-censor'] = $this->getConfigInformation($input, $output); - - $this->writeConfigFile($conf); + $this->reloadConfig(); $this->setupDatabase($output); $admin = $this->getAdminInformation($input, $output); @@ -447,8 +454,10 @@ class InstallCommand extends Command { $output->write('Setting up your database...'); - shell_exec(ROOT_DIR . 'bin/console php-censor-migrations:migrate'); + $outputMigration = shell_exec(ROOT_DIR . 'bin/console php-censor-migrations:migrate'); + $output->writeln(''); + $output->writeln($outputMigration); $output->writeln('OK'); } @@ -461,8 +470,6 @@ class InstallCommand extends Command protected function createAdminUser($admin, $output) { try { - $this->reloadConfig(); - /** @var UserStore $userStore */ $userStore = Factory::getStore('User'); $userService = new UserService($userStore); diff --git a/src/PHPCensor/Console/Application.php b/src/PHPCensor/Console/Application.php index c405fda0..6b407f92 100644 --- a/src/PHPCensor/Console/Application.php +++ b/src/PHPCensor/Console/Application.php @@ -50,7 +50,7 @@ class Application extends BaseApplication if ($databaseSettings) { $phinxSettings = [ 'paths' => [ - 'migrations' => 'src/PHPCensor/Migrations', + 'migrations' => ROOT_DIR . 'src/PHPCensor/Migrations', ], 'environments' => [ 'default_migration_table' => 'migration', diff --git a/tests/PHPCensor/Command/InstallCommandTest.php b/tests/PHPCensor/Command/InstallCommandTest.php index 0e3f2a30..95ee1ba1 100644 --- a/tests/PHPCensor/Command/InstallCommandTest.php +++ b/tests/PHPCensor/Command/InstallCommandTest.php @@ -167,8 +167,8 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase $this->executeWithoutParam('--db-port', $dialog); // Check that specified arguments are correctly loaded. - $this->assertEquals(0, $this->config['b8']['database']['servers']['read'][0]['port']); - $this->assertEquals(0, $this->config['b8']['database']['servers']['write'][0]['port']); + $this->assertArrayNotHasKey('port', $this->config['b8']['database']['servers']['read'][0]); + $this->assertArrayNotHasKey('port', $this->config['b8']['database']['servers']['write'][0]); } public function testDatabasePortConfig() From 55a4dfcb2d343bc9204389acd260f655f2a3631f Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Sun, 5 Feb 2017 14:40:30 +0700 Subject: [PATCH 11/13] Installation fix --- src/PHPCensor/Command/InstallCommand.php | 31 +++++++++++++----------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/PHPCensor/Command/InstallCommand.php b/src/PHPCensor/Command/InstallCommand.php index afe4ff41..97762a1f 100644 --- a/src/PHPCensor/Command/InstallCommand.php +++ b/src/PHPCensor/Command/InstallCommand.php @@ -46,10 +46,10 @@ class InstallCommand extends Command ->addOption('admin-name', null, InputOption::VALUE_OPTIONAL, 'Admin name') ->addOption('admin-password', null, InputOption::VALUE_OPTIONAL, 'Admin password') ->addOption('admin-email', null, InputOption::VALUE_OPTIONAL, 'Admin email') - ->addOption('queue-use', null, InputOption::VALUE_OPTIONAL, 'Don\'t ask for queue details') + ->addOption('queue-use', null, InputOption::VALUE_OPTIONAL, 'Don\'t ask for queue details', true) ->addOption('queue-host', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue server hostname') ->addOption('queue-name', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue name') - ->addOption('config-from-file', null, InputOption::VALUE_OPTIONAL, 'Take config from file and ignore options') + ->addOption('config-from-file', null, InputOption::VALUE_OPTIONAL, 'Take config from file and ignore options', false) ->setDescription('Install PHP Censor'); } @@ -245,11 +245,13 @@ class InstallCommand extends Command $url = $helper->ask($input, $output, $question); } + $queueConfig = $this->getQueueInformation($input, $output); + return [ 'language' => 'en', 'per_page' => 10, 'url' => $url, - 'queue' => $this->getQueueInformation($input, $output), + 'queue' => $queueConfig, 'email_settings' => [ 'from_address' => 'no-reply@php-censor.local', 'smtp_address' => null, @@ -305,22 +307,23 @@ class InstallCommand extends Command 'use_queue' => true, ]; - /** @var $helper QuestionHelper */ - $helper = $this->getHelper('question'); - $question = new ConfirmationQuestion('Use beanstalkd to manage build queue? ', false); + $queueConfig['host'] = $input->getOption('queue-host'); + $queueConfig['name'] = $input->getOption('queue-name'); - if (!$helper->ask($input, $output, $question)) { - $output->writeln('Skipping beanstalkd configuration.'); + if (!$queueConfig['host'] && !$queueConfig['name']) { + /** @var $helper QuestionHelper */ + $helper = $this->getHelper('question'); + $question = new ConfirmationQuestion('Use beanstalkd to manage build queue? ', false); - return $skipQueueConfig; - } + if (!$helper->ask($input, $output, $question)) { + $output->writeln('Skipping beanstalkd configuration.'); + + return $skipQueueConfig; + } - if (!$queueConfig['host'] = $input->getOption('queue-host')) { $questionQueue = new Question('Enter your beanstalkd hostname [localhost]: ', 'localhost'); $queueConfig['host'] = $helper->ask($input, $output, $questionQueue); - } - - if (!$queueConfig['name'] = $input->getOption('queue-name')) { + $questionName = new Question('Enter the queue (tube) name to use [php-censor-queue]: ', 'php-censor-queue'); $queueConfig['name'] = $helper->ask($input, $output, $questionName); } From 3b33592741ad38ebe24bb622b99069eb11ec011d Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Sun, 5 Feb 2017 15:21:51 +0700 Subject: [PATCH 12/13] Fixed tests --- tests/PHPCensor/Command/InstallCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/PHPCensor/Command/InstallCommandTest.php b/tests/PHPCensor/Command/InstallCommandTest.php index 95ee1ba1..28f55687 100644 --- a/tests/PHPCensor/Command/InstallCommandTest.php +++ b/tests/PHPCensor/Command/InstallCommandTest.php @@ -100,7 +100,7 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase '--admin-name' => 'admin', '--admin-password' => 'admin-password', '--url' => 'http://php-censor.local', - '--queue-use' => null, + '--queue-use' => false, ]; if (!is_null($exclude)) { From 92361a0894f8b88ede1f6f233f12c2d916fc7563 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Sun, 5 Feb 2017 16:22:59 +0700 Subject: [PATCH 13/13] Improved README (about installation) --- README.md | 66 ++++++++++++++++++++++++++++++++----------- docs/en/README.md | 4 +-- docs/en/installing.md | 25 ---------------- docs/en/updating.md | 11 -------- 4 files changed, 52 insertions(+), 54 deletions(-) delete mode 100644 docs/en/installing.md delete mode 100644 docs/en/updating.md diff --git a/README.md b/README.md index ee59add4..e4363759 100644 --- a/README.md +++ b/README.md @@ -85,38 +85,72 @@ More details about [configuring project](docs/en/configuring_project.md). Installing ---------- -* Go to the directory in which you want to install PHP Censor, for example: `/var/www`; +1. Go to the directory in which you want to install PHP Censor, for example: `/var/www`: -* Download PHP Censor from this repository and unzip it (to `/var/www/php-censor.local` for example); +```bash +cd /var/www +``` -* Go to the PHP Censor directory: `cd /var/www/php-censor.local`; +2. Create project by Composer: -* Install dependencies using Composer: `composer install`; +```bash +composer create-project corpsee/php-censor php-censor.local --keep-vcs +``` -* Create empty database for application; +Or download [latest archive](https://github.com/corpsee/php-censor/releases/latest) from Github, unzip it and run +`composer install`. -* Install Beanstalkd queue (`aptitude install beanstalkd`); +3. Create empty database for application (Mysql/MariaDB or Postgres); -* Install PHP Censor itself: `./bin/console php-censor:install`; +4. Install Beanstalkd Queue (Optional, if you are going to use queue with Worker): -* [Add a virtual host to your web server](docs/en/virtual_host.md), pointing to the `public` directory within your new +```bash +aptitude install beanstalkd # For deb-based +``` + +5. Install PHP Censor itself: + +```bash +cd ./php-censor.local + +# Interactive installation +./bin/console php-censor:install + +# Non-interactive installation +./bin/console php-censor:install --url='http://php-censor.local' --db-type=pgsql --db-host=localhost --db-name=php-censor --db-user=php-censor --db-password=php-censor --db-port=null --admin-name=admin --admin-password=admin --admin-email='admin@php-censor.local' --queue-use=1 --queue-host=localhost --queue-name=php-censor + +# Non-interactive installation with prepared config.yml file +./bin/console php-censor:install --config-from-file=yes --admin-name=admin --admin-password=admin --admin-email='admin@php-censor.local' +``` + +6. [Add a virtual host to your web server](docs/en/virtual_host.md), pointing to the `public` directory within your new PHP Censor directory. You'll need to set up rewrite rules to point all non-existent requests to PHP Censor; -* [Set up the PHP Censor Worker](docs/en/workers/worker.md), or [a cron-job](docs/en/workers/cron.md) to run PHP -Censor builds; - -More details about [installation](docs/en/installing.md). +7. [Set up the PHP Censor Worker](docs/en/workers/worker.md) (Need configured Queue) or +[a cron-job](docs/en/workers/cron.md) to run PHP Censor builds; Updating -------- -* Go to your PHP Censor directory (to `/var/www/php-censor.local` for example); +1. Go to your PHP Censor directory (to `/var/www/php-censor.local` for example): -* Pull the latest code. This would look like this: `git pull`; +```bash +cd /var/www/php-censor.local +``` -* Update the PHP Censor database: `./bin/console php-censor-migrations:migrate`; +2. Pull the latest code by Git: -* Update the Composer dependencies: `composer install` +```bash +git pull -r +``` + +3. Update the Composer dependencies: `composer install` + +4. Update the PHP Censor database scheme: + +```bash +./bin/console php-censor-migrations:migrate +``` Migrations ---------- diff --git a/docs/en/README.md b/docs/en/README.md index 9f596185..9dfed15a 100644 --- a/docs/en/README.md +++ b/docs/en/README.md @@ -4,13 +4,13 @@ PHP Censor documentation Getting Started --------------- -* [Installing PHP Censor](installing.md) +* Installing PHP Censor (See [README](../../README.md)) * [Adding a Virtual Host](virtual_host.md) * [Run builds using a worker](workers/worker.md) * [Run builds using cronjob](workers/cron.md) * [Adding PHP Censor Support to Your Projects](configuring_project.md) * [Setting up Logging](logging.md) -* [Updating PHP Censor](updating.md) +* Updating PHP Censor (See [README](../../README.md)) * [Configuring PHP Censor](configuring.md) Using PHP Censor diff --git a/docs/en/installing.md b/docs/en/installing.md deleted file mode 100644 index 90011f59..00000000 --- a/docs/en/installing.md +++ /dev/null @@ -1,25 +0,0 @@ -Installing PHP Censor -===================== - -What you'll need ----------------- - -* PHP 5.6.0+ -* A web server (Nginx or Apache) -* [Composer](https://getcomposer.org/download/) -* [Git](http://git-scm.com/downloads) -* A DB server to connect to (MySQL/MariaDB or PostgreSQL). -* The following functions need to be enabled: `exec()`, `shell_exec()` and `proc_open()` in php.ini. -* PHP must have OpenSSL support enabled. - -Installing PHP Censor Manually ------------------------------- - -* Go to the directory in which you want to install PHP Censor, for example: `/var/www` -* [Download PHP Censor](https://github.com/corpsee/php-censor/releases/latest) and unzip it. -* Go to the PHP Censor directory: `cd /var/www/php-censor` -* Install dependencies using Composer: `composer install` -* Install PHP Censor itself: `./bin/console php-censor:install` -* [Add a virtual host to your web server](virtual_host.md), pointing to the `public` directory within your new PHP -Censor directory. You'll need to set up rewrite rules to point all non-existent requests to PHP Censor. -* [Set up the PHP Censor Worker](workers/worker.md), or [a cron-job](workers/cron.md) to run PHP Censor builds. diff --git a/docs/en/updating.md b/docs/en/updating.md deleted file mode 100644 index 8510f9e3..00000000 --- a/docs/en/updating.md +++ /dev/null @@ -1,11 +0,0 @@ -Updating PHP Censor -=================== - -Updating PHP Censor to the latest release, or even dev-master updates is something that will need to be done from time to time. Most of this may be self-explanatory, but for clarity and completeness, it should be added to the documentation. - -1. Go to your PHP Censor root folder in a Terminal. -2. Pull the latest code. This would look like this: `git pull` -3. Update the PHP Censor database: `./bin/console php-censor-migrations:migrate` -4. Update the composer and its packages: `composer self-update && composer update` -5. Return to the PHP Censor admin screens and check your desired plugins are still installed correctly. -7. Run a build to make sure everything is working as expected.