コマンドラインツールの使い方
対象:バージョン5.7.5以降
サーバーにSSHでアクセスし、同梱されている concrete/bin/concrete5 ファイルにアクセスすることで、様々なタスクをコマンドラインから行うことができます。このファイルにアクセスするには、適切なパーミッションを与えるようにしてください。
インストール
$ concrete/bin/concrete5 c5:install --db-server=localhost --db-username=root --db-password=root --db-database=concrete5 --site="Concrete5 Demo" --starting-point=elemental_full --admin-email=admin@example.com --admin-password=password --demo-username=demo --demo-password=demo --demo-email=demo@example.com
上記のオプションは、設定ファイルをサーバーに設置しておくことで、毎回指定する必要がなくなります。何度もインストールを繰り返す開発環境に便利です。
$ concrete/bin/concrete5 c5:install --config=default_config.php
設定ファイルは、下記のようにPHPの配列で指定します。
<?php return array( 'db-server' => 'localhost', 'db-username' => 'root', 'db-password' => 'root', 'db-database' => 'concrete5', 'site' => 'Concrete5 Demo', 'starting-point' => 'elemental_full', 'admin-email' => 'admin@example.com', 'admin-password' => 'password', 'demo-username' => 'demo', 'demo-password' => 'demo', 'demo-email' => 'demo@example.com' );
concrete5 8.0.0 以降のオプション
V8.0.0 からは、下記のようなオプションになりました。
c5:install [--db-server DB-SERVER] [--db-username DB-USERNAME] [--db-password DB-PASSWORD] [--db-database DB-DATABASE] [--site SITE] [--canonical-url CANONICAL-URL] [--canonical-ssl-url CANONICAL-SSL-URL] [--starting-point STARTING-POINT] [--admin-email ADMIN-EMAIL] [--admin-password ADMIN-PASSWORD] [--demo-username DEMO-USERNAME] [--demo-password DEMO-PASSWORD] [--demo-email DEMO-EMAIL] [--language LANGUAGE] [--site-locale SITE-LOCALE] [--config CONFIG] [--attach] [--force-attach] [-i|--interactive]
リセット
$ concrete/bin/concrete5 c5:reset
concrete5 をインストール前の状態にリセットします。データベースを空にしアップロードファイルを削除します。
ジョブの実行
実行可能なジョブの一覧の取得
$ concrete/bin/concrete5 c5:job --list
ジョブの実行
$ concrete/bin/concrete5 c5:job index_search_all generate_sitemap
ジョブハンドルを指定して実行します。ジョブは複数指定可能です。
Config
設定値の取得
$ concrete/bin/concrete5 c5:config get concrete.site
Concrete5 Demo
設定値の上書き
$ concrete/bin/concrete5 c5:config set concrete.site "My Great Site"
コマンドラインから設定した値は、application/config/concrete.php に書き込まれます。ファイルに書き込まれた設定値は、データベースに保存されている値を上書きします。
※ -e オプションで環境を指定することもできます。
利用可能なコマンドの一覧表示
$ concrete/bin/concrete5 concrete5 version 5.7.5.4 Usage: command [options] [arguments] Options: -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Available commands: help Displays help for a command list Lists commands c5 c5:clear-cache Clear the concrete5 cache c5:config Set or get configuration parameters. c5:ide-symbols Generate IDE symbols c5:install Install concrete5 c5:job Run a concrete5 job c5:package-install Install a concrete5 package c5:package-pack Process a package (expand PHP short tags, compile icons and translations, create zip archive) c5:package-translate Creates or updates translations of a concrete5 package c5:package-uninstall Uninstall a concrete5 package c5:package-update Update a concrete5 package c5:reset Reset the concrete5 installation, deleting files and emptying the database dbal dbal:import Import SQL file(s) directly to Database. dbal:run-sql Executes arbitrary SQL directly from the command line. migrations migrations:diff Generate a migration by comparing your current database to your mapping information. migrations:execute Execute a single migration version up or down manually. migrations:generate Generate a blank migration class. migrations:migrate Execute a migration to a specified version or the latest available version. migrations:status View the status of a set of migrations. migrations:version Manually add and delete migration versions from the version table. orm orm:clear-cache:metadata Clear all metadata cache of the various cache drivers. orm:clear-cache:query Clear all query cache of the various cache drivers. orm:clear-cache:result Clear all result cache of the various cache drivers. orm:convert-d1-schema Converts Doctrine 1.X schema into a Doctrine 2.X schema. orm:convert-mapping Convert mapping information between supported formats. orm:convert:d1-schema Converts Doctrine 1.X schema into a Doctrine 2.X schema. orm:convert:mapping Convert mapping information between supported formats. orm:ensure-production-settings Verify that Doctrine is properly configured for a production environment. orm:generate-entities Generate entity classes and method stubs from your mapping information. orm:generate-proxies Generates proxy classes for entity classes. orm:generate-repositories Generate repository classes from your mapping information. orm:generate:entities Generate entity classes and method stubs from your mapping information. orm:generate:proxies Generates proxy classes for entity classes. orm:generate:repositories Generate repository classes from your mapping information. orm:info Show basic information about all mapped entities orm:run-dql Executes arbitrary DQL directly from the command line. orm:schema-tool:create Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output. orm:schema-tool:drop Drop the complete database schema of EntityManager Storage Connection or generate the corresponding SQL output. orm:schema-tool:update Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata. orm:validate-schema Validate the mapping files.
パッケージからコマンドを追加する
パッケージコントローラーの on_start() メソッドからアドオンに同梱されているコマンドをconcrete5に登録できます。
public function on_start() { if (Core::make('app')->isRunThroughCommandLineInterface()) { try { $app = Core::make('console'); $app->add(new ExampleCommand()); } catch (Exception $e) {} } }