1
|
# Environment
|
2
|
|
3
|
This component provides functionality that helps writing PHP code that has runtime-specific (PHP / HHVM) execution paths.
|
4
|
|
5
|
[](https://packagist.org/packages/sebastian/environment)
|
6
|
[](https://travis-ci.org/sebastianbergmann/environment)
|
7
|
|
8
|
## Installation
|
9
|
|
10
|
To add Environment as a local, per-project dependency to your project, simply add a dependency on `sebastian/environment` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on Environment 1.0:
|
11
|
|
12
|
{
|
13
|
"require": {
|
14
|
"sebastian/environment": "1.0.*"
|
15
|
}
|
16
|
}
|
17
|
|
18
|
## Usage
|
19
|
|
20
|
```php
|
21
|
<?php
|
22
|
use SebastianBergmann\Environment\Runtime;
|
23
|
|
24
|
$runtime = new Runtime;
|
25
|
|
26
|
var_dump($runtime->getNameWithVersion());
|
27
|
var_dump($runtime->getName());
|
28
|
var_dump($runtime->getVersion());
|
29
|
var_dump($runtime->getBinary());
|
30
|
var_dump($runtime->isHHVM());
|
31
|
var_dump($runtime->isPHP());
|
32
|
var_dump($runtime->hasXdebug());
|
33
|
var_dump($runtime->canCollectCodeCoverage());
|
34
|
```
|
35
|
|
36
|
### Output on PHP
|
37
|
|
38
|
$ php --version
|
39
|
PHP 5.5.8 (cli) (built: Jan 9 2014 08:33:30)
|
40
|
Copyright (c) 1997-2013 The PHP Group
|
41
|
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
|
42
|
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
|
43
|
|
44
|
|
45
|
$ php example.php
|
46
|
string(9) "PHP 5.5.8"
|
47
|
string(3) "PHP"
|
48
|
string(5) "5.5.8"
|
49
|
string(14) "'/usr/bin/php'"
|
50
|
bool(false)
|
51
|
bool(true)
|
52
|
bool(true)
|
53
|
bool(true)
|
54
|
|
55
|
### Output on HHVM
|
56
|
|
57
|
$ hhvm --version
|
58
|
HipHop VM 2.4.0-dev (rel)
|
59
|
Compiler: heads/master-0-ga98e57cabee7e7f0d14493ab17d5c7ab0157eb98
|
60
|
Repo schema: 8d6e69287c41c1f09bb4d327421720d1922cfc67
|
61
|
|
62
|
|
63
|
$ hhvm example.php
|
64
|
string(14) "HHVM 2.4.0-dev"
|
65
|
string(4) "HHVM"
|
66
|
string(9) "2.4.0-dev"
|
67
|
string(42) "'/usr/local/src/hhvm/hphp/hhvm/hhvm' --php"
|
68
|
bool(true)
|
69
|
bool(false)
|
70
|
bool(false)
|
71
|
bool(true)
|
72
|
|