Command line interface
cli.php
is a command line wrapper for running commands that aid administration of your Jadu Central. Commands includes functionality such as clearing cache, fixing version data or resetting stuck queues. In the near future, additional commands will become available.
cli.php
has been written in a way so that's it's easily extendable. Each command is added to config and must extend the Jadu\Abstracts\AbstractCommand
class.
Jadu Central is shipped with a command line tool to assist system administrators in performing some of the most commonly used actions on the server, such as clearing the cache, initialising schedule tasks, etc.
The cli.php
script is located in the home directory of Jadu Central.
php cli.php --list Lists all the available commands. php cli.php [command] --help Displays detailed usage for the said command.
cms:clear-cache
Clears the database, symfony and configuration cache for a site.
Arguments | |
---|---|
siteurl | Site for which the cache needs to be cleared. If no siteURL is given, all sites' cache will be cleared. |
php cli.php cms:clear-cache php cli.php cms:clear-cache galaxy.example.jadu.net
cms:fix-queues
To fix the schedule tasks that may be stuck in the past. This resets the nextRunDate and scheduleTime in the JaduScheduleTasks table of mainsite and galaxies sites.
php cli.php cms:fix-queues
cms:import-llpg
To import a DTF file into the database. As a pre-requisite, LLPG_DTF_UPLOAD_DIRECTORY
constant should be set, llpg file should be made available in the said directory with write permissions.
php cli.php cms:import-llpg
cms:db-find-and-replace
Find and replace the URLs in the text fields in the database. We suggest running the command with --findOnly
prior to making the actual replace.
Arguments | |
---|---|
-f, --find=TEXT | String to be matched in the database. |
-r, --replace=TEXT | String to be replaced in the database. |
--useRegex | Flag to be set if the user intends to find the string using regex. |
--findOnly | Flag to be set if the user intends to only find the string and not replace. |
--site=SITE | Site on which the database find and replace needs to be executed. |
--preserveTimestamp | Flag to be set if the user intends to make changes to database without updating the modification date/time. |
php cli.php cms:db-find-and-replace --find "foo" --replace "bar" php cli.php cms:db-find-and-replace --find "foo" --replace "bar" --findOnly php cli.php cms:db-find-and-replace --find "f[\w]+" --replace "bar" --useRegex php cli.php cms:db-find-and-replace --find "foo" --replace "bar" --preserveTimestamp php cli.php cms:db-find-and-replace --find "foo" --replace "bar" --site "example.jadu.net"
Calling commands from code
To call commands from code you must use the CommandInvoker
. This is available from the Jadu_Service_Container
object.
$invoker = Jadu_Service_Container::getInstance()->getCommandInvoker();
// To get an array of commands defined within config $invoker->getConfigurableCommands();
// To get an array of available commands $invoker->getAvailableCommands();
// To run a single command called "myCommand" $invoker->run('myCommand');
Data generation
The cli tool supports random generation of select entities records. Currently, the supported types are:
- admins
- users
- documents
- news
- events
- downloads
The generation command is only available in the Symfony DEV environment, thus commands must be prefixed with SYMFONY_ENV=dev
, provided no environment variable is set.
Usage
The command follows the format:
php cli.php test:generate:<type_name> <amount>
Where:
type_name
is one of the aforementioned supported types.amount
is the number indicating the amount of the type to geneate.
For example, say we wanted to generate 10 documents, we'd run the following command within the home directory of Jadu :
SYMFONY_ENV=dev php cli.php test:generate:documents 10