1. Go to this page and download the library: Download axy/env library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
axy / env example snippets
use axy\env\Factory;
class Service
{
public function __construct($env = null)
{
$this->env = Factory::create($env);
}
public function action()
{
$timeOfAction = $this->env->getCurrentTime();
// ...
}
private $env;
}
// ...
$service = new Service();
$service->action();
$service = new Service(['time' => '2014-11-04 10:11:12']);
$service->action(); // the service will receive the specified time
/**
* Cron daemon
* Once an hour to kill, not to eat a lot of memory
*/
$startTime = time();
while (time() - $startTime() < 3500) {
step();
sleep(5);
}
$config = [
'functions' => [
'header' => function ($header) {
// save header to a local storage
},
],
];
$env = new Env();
$env->header('Content-Type: text/plain'); // The header will not be sent
if ($env->isFunctionExists('getallheaders')) {
return $env->getallheaders();
}
$config = [
'functions' => [
'getallheaders' => function () {
if (function_exists('getallheaders')) {
return getallheaders();
} else {
return parseServerVarsForHeaders();
}
},
],
];
// now $env->getallheaders() always available
use axy\env\Factory;
class Service
{
public function __construct($env = null)
{
$this->env = Factory::create($env);
}
// ...
}
$service = new Service(['time' => '2011-01-01']);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.