generate:api subcommand (and a few others) require access to a working copy of CiviCRM.
To locate this, it uses a process reminiscent of
wp-cli. For example, if the command-line is running inside
/var/www/sites/default/files/civicrm/ext/org.example.foo/, then it will perform an upward search to find the CMS root:
In each case, it is looking for a tell-tale sign of a CMS+Civi system. For example, in a typical Drupal installation, you'd expect to see the file
There are some cases where the default search may not work correctly, e.g.
- Using a new or custom CMS.
- Using a multisite configuration.
- Using symlinks.
The quickest way to resolve this? Don't rely on a search. Instead, tell
civix specifically where to find your copy of CiviCRM by setting the variable
civix generate:api ...
More aggressive ways to resolve this would be:
- Arrange your directory structure so that it looks like a normal build (e.g. replace symlinks with real folders).
civibuild for your dev sites. It always produces standard builds.
- Submit a patch for
Civi/Cv/Bootstrap to add support for your directory structure.