Download the PHP package civicrm/cv without Composer
On this page you can find all versions of the php package civicrm/cv. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package cv
cv
The cv
command is a utility for interacting with a CiviCRM installation. It performs an automatic scan to locate and boot the CiviCRM installation. It provides command-line access to helper functions and configuration data, such as APIv3 and site URLs.
Requirements
- PHP v7.3+.
- A local CiviCRM installation.
- Systems with special file-layouts may need to configure bootstrap.
Download
cv
is distributed in PHAR format, which is a portable executable file (for PHP). It should run on most Unix-like systems where PHP is installed.
Here are three quick ways to download it:
-
Download the latest release of
cv.phar
(SHA256, GPG) and put it in the PATH. For example:(Learn more: Install
cv.phar
as system-wide tool (Linux/BSD/macOS)) -
Or... add
cv
and other CiviCRM tools to a composer project (Drupal 9/10/11)(Learn more: Install
cv.phar
as project tool (composer)) -
Or... use phar.io's
phive
installer to download, validate, and cache thecv.phar
file.(Learn more: Install
cv.phar
as project tool (phive))
There are several more options for downloading cv
. See also:
- Download URLs for alternate versions
- Comparison of install options
- Install
cv
as a system-wide/standalone tool- Install
cv.phar
(binary) as system-wide tool (Linux/BSD/macOS) - Install
cv.git
(source) as standalone project (Linux/BSD/macOS) - Install
cv.git
(source) as standalone project (Windows)
- Install
- Install
cv
as a tool within another project- Install
cv.phar
(binary) as project tool (composer) - Install
cv.phar
(binary) as project tool (phive) - Install
cv.git
(source) as project tool (composer)
- Install
Documentation
cv
provides a number of subcommands. To see a list, run cv
without any arguments.
For detailed help about a specific subcommand, use -h
as in cv api -h
.
There are some general conventions:
- Many subcommands support common bootstrap options, such as
--user
,--level
, and--test
. - Many subcommands support multiple output formats using
--out
. You may set a general preference with an environment variable, e.g.export CV_OUTPUT=json-pretty
orexport CV_OUTPUT=php
.
Example: CLI
If you intend to run unit-tests, and if you do not use civibuild
,
then you may need to supply some additional site information (such as
the name of the test users). To do this, run:
Example: PHP
Suppose you have a standalone script or a test runner which needs to execute
in the context of a CiviCRM site. You don't want to hardcode it to a
specific path, create special-purpose config files, or require a specific
directory structure. Instead, call cv php:boot
and eval()
. The simplest way:
However, it is better to create a small wrapper function to improve error-handling and output parsing:
Example: NodeJS
See https://github.com/civicrm/cv-nodejs
Bootstrap
cv
must find and bootstrap the local instance of CiviCRM, Drupal, WordPress, or similar. This may work a few ways:
-
Automatic: By default,
cv
checks the current directory and each parent directory for evidence of well-known environment (such as Drupal or WordPress).The automatic search is designed to work with a default site-layout -- as seen in a typical "zip" or "tar" file from
drupal.org
,wordpress.org
, or similar. Some deployments add more advanced options -- such as configuring "multi-site", adding bespoke "symlinks", or moving thewp-admin
folder. For advanced layouts, you may need to set an environment variable. -
__
CIVICRM_BOOT
__ (new protocol): Boot the CMS first (and then ask it to boot CiviCRM). This is more representative of a typical HTTP page-view, and it is compatible with commands likecore:install
. Set this environment variable to specify the CMS type and base-directory. Compare: -
__
CIVICRM_SETTINGS
__ (old protocol): Boot CiviCRM first (and then ask it to boot the CMS). Set this environment variable to specify thecivicrm.settings.php
location. Compare:(Note: In the legacy protocol,
cv
loads CiviCRM and then asks CiviCRM to boostrap the CMS. However, it is less representative of a typical HTTP page-view, and it is incompatible with commands likecore:install
. You might use it for headless testing or as fallback/work-around if any bugs are discovered in the standard protocol.)
NOTE: In absence of a configuration variable, the Automatic mode will behave like
CIVICRM_SETTINGS="Auto"
(in v0.3.x). This is tentatively planned to change in v0.4.x, where it will behave likeCIVICRM_BOOT="Auto://."
Additionally, some deployments handle multiple sites ("multisite"/"multidomain"). You should target a specific site using --hostname
or HTTP_HOST
.
Here are a few examples of putting these together:
Autocomplete
There is limited/experimental support for shell autocompletion based on stecman/symfony-console-completion. To enable it:
Development
For more information, see doc/develop.md.
All versions of cv with dependencies
ext-json Version *
cweagans/composer-patches Version ~1.0
lesser-evil/shell-verbosity-is-evil Version ~1.0
symfony/console Version ~5.4
symfony/process Version ~5.4
psr/log Version ~1.1 || ~2.0 || ~3.0
psy/psysh Version @stable
stecman/symfony-console-completion Version ^0.11.0