diff --git a/app/phinx.php b/app/phinx.php deleted file mode 100644 index e2a5dc7e..00000000 --- a/app/phinx.php +++ /dev/null @@ -1,36 +0,0 @@ -get('b8.database.servers.write'); - -if (!is_array($writeServers)) { - $writeServers = [$writeServers]; -} - -$conf = [ - 'paths' => [ - 'migrations' => 'src/PHPCensor/Migrations', - ], - 'environments' => [ - 'default_migration_table' => 'migration', - 'default_database' => 'php-censor', - 'php-censor' => [ - 'adapter' => 'mysql', - 'host' => end($writeServers), - 'name' => $config->get('b8.database.name'), - 'user' => $config->get('b8.database.username'), - 'pass' => $config->get('b8.database.password'), - ], - ], -]; - -return $conf; diff --git a/bin/console b/bin/console index 4d1cddd7..9360d461 100755 --- a/bin/console +++ b/bin/console @@ -11,7 +11,6 @@ use PHPCensor\Command\RunCommand; use PHPCensor\Command\RebuildCommand; -use PHPCensor\Command\UpdateCommand; use PHPCensor\Command\InstallCommand; use PHPCensor\Command\DaemonCommand; use PHPCensor\Command\PollCommand; @@ -20,8 +19,8 @@ use PHPCensor\Command\CreateBuildCommand; use PHPCensor\Command\WorkerCommand; use PHPCensor\Command\RebuildQueueCommand; use PHPCensor\Service\BuildService; -use Symfony\Component\Console\Application; use b8\Store\Factory; +use PHPCensor\Console\Application; define('IS_CONSOLE', true); @@ -32,7 +31,6 @@ $application = new Application(); $application->add(new RunCommand($loggerConfig->getFor('RunCommand'))); $application->add(new RebuildCommand($loggerConfig->getFor('RunCommand'))); $application->add(new InstallCommand); -$application->add(new UpdateCommand($loggerConfig->getFor('UpdateCommand'))); $application->add(new DaemonCommand($loggerConfig->getFor('DaemonCommand'))); $application->add(new PollCommand($loggerConfig->getFor('PollCommand'))); $application->add(new CreateAdminCommand(Factory::getStore('User'))); diff --git a/docs/en/installing.md b/docs/en/installing.md index 0880aab1..d3814259 100644 --- a/docs/en/installing.md +++ b/docs/en/installing.md @@ -19,7 +19,7 @@ Installing PHP Censor from Composer * Download Composer if you haven't already: `curl -sS https://getcomposer.org/installer | php` * Download PHP Censor: `./composer.phar create-project corpsee/php-censor php-censor --keep-vcs --no-dev` * Go to the newly created PHP Censor directory, and install Composer dependencies: `cd php-censor && ../composer.phar install` -* Run the PHP Censor installer: `./console php-censor:install` +* Run the PHP Censor installer: `./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 you can run builds using the [daemon](workers/daemon.md) or [a cron-job](workers/cron.md) to run PHP Censor builds. @@ -30,6 +30,6 @@ Installing PHP Censor Manually * [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: `./console php-censor: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 you can run builds using the [daemon](workers/daemon.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 index 74a5380c..33bb8e8c 100644 --- a/docs/en/updating.md +++ b/docs/en/updating.md @@ -5,7 +5,7 @@ Updating PHP Censor to the latest release, or even dev-master updates is somethi 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: `./console php-censor:update` +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. diff --git a/docs/en/workers/cron.md b/docs/en/workers/cron.md index d0a2da1f..d3c69f08 100644 --- a/docs/en/workers/cron.md +++ b/docs/en/workers/cron.md @@ -11,7 +11,7 @@ Setting up the Cron Job You'll want to set up PHP Censor to run as a regular cronjob, so run `crontab -e` and enter the following: ```sh -* * * * * /usr/bin/php /path/to/php-censor/console php-censor:run-builds +* * * * * /usr/bin/php /path/to/php-censor/bin/console php-censor:run-builds ``` **Note:** Make sure you change the `/path/to/php-censor` to the directory in which you installed PHP Censor, and update the PHP path if necessary. diff --git a/docs/en/workers/worker.md b/docs/en/workers/worker.md index 07be7937..c9ea6a71 100644 --- a/docs/en/workers/worker.md +++ b/docs/en/workers/worker.md @@ -37,7 +37,7 @@ Using your preferred text editor, create a file named `php-censor.conf` under `/ ``` [program:php-censor] -command=/path/to/php-censor/latest/console php-censor:worker +command=/path/to/php-censor/bin/console php-censor:worker process_name=%(program_name)s_%(process_num)02d stdout_logfile=/var/log/php-censor.log stderr_logfile=/var/log/php-censor-err.log diff --git a/src/PHPCensor/Command/InstallCommand.php b/src/PHPCensor/Command/InstallCommand.php index 6a641a6a..dc926024 100644 --- a/src/PHPCensor/Command/InstallCommand.php +++ b/src/PHPCensor/Command/InstallCommand.php @@ -382,9 +382,7 @@ class InstallCommand extends Command { $output->write(Lang::get('setting_up_db')); - $phinxBinary = escapeshellarg(ROOT_DIR . 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'phinx'); - $phinxScript = escapeshellarg(APP_DIR . 'phinx.php'); - shell_exec($phinxBinary . ' migrate -c ' . $phinxScript); + shell_exec(ROOT_DIR . 'bin/console php-censor-migrations:migrate'); $output->writeln(''.Lang::get('ok').''); } diff --git a/src/PHPCensor/Command/UpdateCommand.php b/src/PHPCensor/Command/UpdateCommand.php deleted file mode 100644 index 180460d1..00000000 --- a/src/PHPCensor/Command/UpdateCommand.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @package PHPCI - * @subpackage Console - */ -class UpdateCommand extends Command -{ - /** - * @var \Monolog\Logger - */ - protected $logger; - - public function __construct(Logger $logger, $name = null) - { - parent::__construct($name); - $this->logger = $logger; - } - - protected function configure() - { - $this - ->setName('php-censor:update') - ->setDescription(Lang::get('update_app')); - } - - /** - * Generates Model and Store classes by reading database meta data. - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - if (!$this->verifyInstalled()) { - return; - } - - $output->write(Lang::get('updating_app')); - - shell_exec(ROOT_DIR . 'vendor/bin/phinx migrate -c "' . APP_DIR . 'phinx.php"'); - - $output->writeln(''.Lang::get('ok').''); - } - - protected function verifyInstalled() - { - $config = Config::getInstance(); - $url = $config->get('php-censor.url'); - - return !empty($url); - } -} diff --git a/src/PHPCensor/Console/Application.php b/src/PHPCensor/Console/Application.php new file mode 100644 index 00000000..5df1c378 --- /dev/null +++ b/src/PHPCensor/Console/Application.php @@ -0,0 +1,68 @@ +get('b8.database', []); + + $phinxSettings = [ + 'paths' => [ + 'migrations' => 'src/PHPCensor/Migrations', + ], + 'environments' => [ + 'default_migration_table' => 'migration', + 'default_database' => 'php-censor', + 'php-censor' => [ + 'adapter' => 'mysql', + 'host' => $databaseSettings['servers']['write'], + 'name' => $databaseSettings['name'], + 'user' => $databaseSettings['username'], + 'pass' => $databaseSettings['password'], + ], + ], + ]; + + $phinxConfig = new PhinxConfig($phinxSettings); + + $this->add( + (new Create()) + ->setConfig($phinxConfig) + ->setName('php-censor-migrations:create') + ); + $this->add( + (new Migrate()) + ->setConfig($phinxConfig) + ->setName('php-censor-migrations:migrate') + ); + $this->add( + (new Rollback()) + ->setConfig($phinxConfig) + ->setName('php-censor-migrations:rollback') + ); + $this->add( + (new Status()) + ->setConfig($phinxConfig) + ->setName('php-censor-migrations:status') + ); + } +} diff --git a/src/PHPCensor/Controller/BuildController.php b/src/PHPCensor/Controller/BuildController.php index 73a15f47..6bc2d353 100644 --- a/src/PHPCensor/Controller/BuildController.php +++ b/src/PHPCensor/Controller/BuildController.php @@ -1,4 +1,5 @@