Shell commands
A number of administration tasks can be performed via shell.
All shells and commands listed below can be invoked via a binary that’s located
in the bin/
directory. The basic syntax is:
$ bin/cake SHELL [COMMAND] [argument1 argument2 ...] [--option1 --option2=val ...]
Warning
Windows users must use bin\cake
instead (note the backslash).
For instance, if you want to run the setup command in the bedita shell you can run:
$ bin/cake bedita setup
If you want to run the init command in the db_admin shell with a couple of additional options you can run:
$ bin/cake db_admin init --no-force --seed
Note
Bash autocomplete might come in handy
bedita
The bedita
shell is the first place you’ll ever want to search in
when you’re looking for a tool to perform an administrative task.
setup
The setup
subcommand will lead you through the several steps required to
get a new BEdita instance to work.
You’ll be asked for database connection credentials, as well as user credentials for the first administrator user to be added to the system.
Additional steps, like checking for correct permissions on some folders, creating database tables, or checking if current database schema is up-to-date with the latest changes, are performed.
It is safe to run this command again once BEdita has been initialized.
- -y, --yes
Run in non-interactive mode.
- --config-file <path>
Path to configuration file (default:
config/app.php
).
- Example
$ bin/cake bedita setup
db_admin
The db_admin
shell is specialized in database administration tasks
for developers. As a user of BEdita, you’ll hardly need any of the commands
that this shell provides.
init
This subcommand will initialize the database. The database connection must be already configured in order for this command to work. If you’re looking for a command-line wizard to guide you through all the steps required to install BEdita, please head to the setup command.
If any table is present in the database, you’ll be asked if you want your database to be weeped, or if you wish to abort the operation. When the schema has been created, you’ll also be asked if you want additional set of data to be loaded into the database. A minimum set of data is loaded regardless of your choice — this is required in order for BEdita to work.
This command can be run in unattended (non-interactive) mode by appending
command-line flags --[no-]force
and --[no-]seed
.
- -f, --force
Force removal of all tables in case target database is not empty.
- --no-force
Abort if target database is not empty.
- -s, --seed
Seed database with additional set of data.
- --no-seed
Don’t load any additional set of data. A minimum set of data required for BEdita to work is loaded anyway.
- -c <connection>, --connection <connection>
Database connection to be used (default:
default
).
- Example
$ bin/cake db_admin init --no-force --seed
check_schema
This subcommand will perform checks on the current schema. This command is mostly useful when developing features that require making changes to the schema of BEdita’s database.
You’ll be notified of:
migration history not in sync (schema not migrated to the latest available version)
new changes (added or removed tables; changes to columns, indexes or constraints)
naming that offends SQL conventions
This command exits with a non-zero exit code whenever current schema is not completely up-to-date and it follows SQL conventions, making it possible to employ this command in other automated tasks.
- -c <connection>, --connection <connection>
Database connection to be used (default:
default
).
- Example
$ bin/cake db_admin check_schema --verbose
jobs
The jobs
shell is used to run asynchonous pending jobs stored in async_jobs table.
pending
The pending
subcommand will launch all pending jobs waiting to be run.
A --limit
option may be used to set a maximum number of jobs to run.
- -l <limit>, --limit <limit>
Specify maximum number of jobs to run.
- Example
$ bin/cake jobs pending -l 10
run
The run
subcommand will launch a single job from its UUID.
- Example
$ bin/cake jobs run 0660d795-d1bf-4ca0-9a05-2ee47943a658
spec
The spec
shell can be used to automatically generate piece of documentation
for available API endpoints.
generate
The generate
subcommand will generate Swagger documentation in YAML format
for currently available API endpoints.
- -o <output>, --output <output>
Specify an output file (default:
plugins/BEdita/API/spec/be4.yaml
).
- Example
$ bin/cake spec generate
tree
The tree
shell provides two tasks: check
and recover
.
check
It performs some object-aware checks such as:
detect folders that are not in the tree
detect ubiquitous folders
detect non-folder objects that are roots
detect non-folder objects that have descendants
detect objects that are present more than once within same parent
Usage: bin/cake tree check
.
recover
It performs a basic recovery of a corrupt tree, by simply invoking CakePHP’s TreeBehavior::recover().
Usage: bin/cake tree recover
.