cv (https://github.com/civicrm/cv) and
civix (https://github.com/totten/civix) are Unix/CLI tools for developers.
cv provides access to your Civi site on the command line, and
civix generates skeletal code for new extensions. We've had a few recent updates to each of these tools, so I wanted to introduce
cv more formally and then recap some of recent improvements for each tool.
cv originated as part of the Testapalooza project which broadened support for automated tests in CiviCRM -- testing of CiviCRM extensions or external integration modules; testing with PHPUnit or Behat or Codeception; testing for headless scenarios or end-to-end scenarios; ad nauseum. In all of these cases, we start with some existing PHP tool (such as
phpunit) and mix-in Civi+CMS.
For example, if you have
cv installed, then your other PHP programs can start CiviCRM with one line:
cv enables you to run PHP code in Civi using four different flows:
cv php:boot): Generate PHP code for booting your CiviCRM instance. You can use this code inside another script, such as
cv php:eval [snippet]aka
cv ev [snippet]): Evaluate a small snippet of PHP code within your CiviCRM instance.
cv php:script [file]aka
cv scr [file]): Execute any PHP script file within your CiviCRM instance.
cv cli): Open an interactive prompt where you can enter several PHP statements. (This is based on the incredible Psysh tool.)
It also includes a few sub-commands which can be useful for writing tests:
cv api): Execute an API call. Inputs and outputs may be encoded as JSON.
cv url): Lookup the URL for any Civi page, with suitable adjustments to match the current CMS and domain.
cv vars:show): Export data about the DSN, URL, and demo users.
cv is similar to
joomla-console in that it provides CLI access to a CiviCRM installation. However, it differs in that:
cv dl [extension-name]. See PR #4 for more complete details.
cvshould now work better with vanilla Joomla environments. Special thanks to Andrew Hunt for fixing and testing this.
cvdoesn't boot correctly in your environment, pass
-vvvto display more verbose information. Special thanks to Erich Schulz for initiating this.
protractor, then you may occasionally need access to CiviCRM paths, URLs, databases, or demo users. Instead of hardcoding these details, you can use the library
civicrm-cv(https://github.com/civicrm/cv-nodejs) to get programmatic access.
cvto access your local CiviCRM instance. The
cvimprovements initiated by Andrew and Erich also improve
releaseDate, or other properties of
info.xml. Use the new sub-commands
civixupgrader traditionally stored a version number in
civicrm_setting. However, this did not work well in multi-domain configurations. The upgrader now tracks the version in
civicrm_extension. Special thanks to Frank Gomez for initiating this.
sql/auto_install.sql) and Smarty-based SQL templates (
sql/auto_install.mysql.tpl). Special thanks to Sunil Pawar for initiating this improvement.
coder. Special thanks to Coleman Watts for initiating these changes.
Note: If you'd like to upgrade an existing extension with newer templates from
civix, see UPGRADE.md.
civixhave built-in help screens to list sub-commands and arguments.
civixare command-line PHP tools. They are distributed as platform-independent executables (PHAR), but they are only tested in certain builds of Linux and OS X. They may or may not work well on Windows -- in either case, trying them on Windows will require more skills/experience with Windows PHP CLI. If you'd like to improve Windows support, please open a pull-request on Github.
civibuildconfigurations: CiviCRM can be deployed with many system configurations using techniques like symlinks, multiple URLs, dynamic database credentials, and so on. However, these techniques often impact the bootstrap process, and we cannot test every possible configuration.
cvis only tested with the
wp-demo. If you'd like to improve support other configurations, please open a pull-request on Github.