Environment
class Environment (View source)
Store information about the environment
Properties
protected string | $homeDir | ||
protected string | $originalCwd | ||
protected string | $etcPrefix | ||
protected string | $sharePrefix | ||
protected string | $drushBasePath | ||
protected string | $vendorDir | ||
protected string|null | $docPrefix | ||
protected string | $configFileVariant | ||
protected ClassLoader | $loader | ||
protected ClassLoader|null | $siteLoader |
Methods
Environment constructor
Return the name of the user running drush.
No description
Convert the environment object into an exported configuration array.
The base directory of the Drush application itself (where composer.json et.al. are found)
Get the site:set alias from the current site:set file path.
User's home directory
The user's Drush configuration directory, ~/.drush
No description
Get the config file variant -- defined to be the Drush major version number. This is for loading drush.yml and drush10.yml, etc.
The original working directory
Return the path to Drush's vendor directory
The class loader returned when the autoload.php file is included.
Set the class loader from the autload.php file, if available.
Alter our default locations based on the value of environment variables.
Set the directory prefix to locate the directory that Drush will use as /etc (e.g. during the functional tests).
Set the directory prefix to locate the directory that Drush will use as /user/share (e.g. during the functional tests).
Return the directory where Drush's documentation is stored. Usually this is within the Drush application, but some Drush RPM distributions & c. for Linux platforms slice-and-dice the contents and put the docs elsewhere.
Locate the Drush documentation. This is recalculated whenever the share prefix is changed.
Check a list of directories and return the first one that exists.
Return the appropriate system path prefix, unless an override is provided.
Return the system configuration path (default: /etc/drush)
Return the system shared commandfile path (default: /usr/share/drush/commands)
Determine whether current OS is a Windows variant.
Verify that we are running PHP through the command line interface.
Get terminal width.
Returns the filename for the file that stores the DRUPAL_SITE variable.
Details
__construct(string $homeDir, string $cwd, string $autoloadFile)
Environment constructor
protected string
getUsername()
Return the name of the user running drush.
protected string
getTmp()
No description
array
exportConfigData()
Convert the environment object into an exported configuration array.
string
drushBasePath()
The base directory of the Drush application itself (where composer.json et.al. are found)
bool|string
getSiteSetAliasName()
Get the site:set alias from the current site:set file path.
string
homeDir()
User's home directory
string
userConfigPath()
The user's Drush configuration directory, ~/.drush
void
setConfigFileVariant($variant)
No description
getConfigFileVariant()
Get the config file variant -- defined to be the Drush major version number. This is for loading drush.yml and drush10.yml, etc.
string
cwd()
The original working directory
string
vendorPath()
Return the path to Drush's vendor directory
ClassLoader|null
loader()
The class loader returned when the autoload.php file is included.
void
setLoader(ClassLoader $loader)
Set the class loader from the autload.php file, if available.
Environment
applyEnvironment()
Alter our default locations based on the value of environment variables.
Environment
setEtcPrefix(mixed $etcPrefix)
Set the directory prefix to locate the directory that Drush will use as /etc (e.g. during the functional tests).
Environment
setSharePrefix(string $sharePrefix)
Set the directory prefix to locate the directory that Drush will use as /user/share (e.g. during the functional tests).
string|null
docsPath()
Return the directory where Drush's documentation is stored. Usually this is within the Drush application, but some Drush RPM distributions & c. for Linux platforms slice-and-dice the contents and put the docs elsewhere.
protected string|bool
findDocsPath(string $drushBasePath)
Locate the Drush documentation. This is recalculated whenever the share prefix is changed.
protected bool|string
findFromCandidates(array $candidates)
Check a list of directories and return the first one that exists.
static protected string
systemPathPrefix(string $override = '', string $defaultPrefix = '')
Return the appropriate system path prefix, unless an override is provided.
string
systemConfigPath()
Return the system configuration path (default: /etc/drush)
string
systemCommandFilePath()
Return the system shared commandfile path (default: /usr/share/drush/commands)
static bool
isWindows($os = null)
Determine whether current OS is a Windows variant.
bool
verifyCLI()
Verify that we are running PHP through the command line interface.
A boolean value that is true when PHP is being run through the command line, and false if being run through cgi or mod_php.
int
calculateColumns()
Get terminal width.
protected string|false
getSiteSetAliasFilePath(string $filename_prefix = 'drush-drupal-site-')
Returns the filename for the file that stores the DRUPAL_SITE variable.