本文整理汇总了PHP中F::Environment方法的典型用法代码示例。如果您正苦于以下问题:PHP F::Environment方法的具体用法?PHP F::Environment怎么用?PHP F::Environment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类F
的用法示例。
在下文中一共展示了F::Environment方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 8.x
*/
setFn('Do', function ($Call) {
if (self::$_Performance or F::Environment() === 'Development') {
$Call['Performance']['Summary']['Time'] = round((microtime(true) - Started) * 1000);
$Call['Performance']['Summary']['Calls'] = array_sum(self::$_Counters['C']);
arsort(self::$_Counters['T']);
F::Log('Max stack size: ' . F::Get('MSS'), LOG_NOTICE, 'Performance');
F::Log('Total time: ' . round($Call['Performance']['Summary']['Time']) . ' ms', LOG_NOTICE, 'Performance');
F::Log('Total calls: ' . $Call['Performance']['Summary']['Calls'], LOG_NOTICE, 'Performance');
F::Log('Total time per call: ' . round($Call['Performance']['Summary']['Time'] / $Call['Performance']['Summary']['Calls'], 2) . ' ms', LOG_NOTICE, 'Performance');
F::Log('Memory: ' . memory_get_usage(true) / 1024 . 'Kb ', LOG_NOTICE, 'Performance');
F::Log('Peak memory: ' . memory_get_peak_usage(true) / 1024 . 'Kb', LOG_NOTICE, 'Performance');
foreach (self::$_Counters['T'] as $Key => $Value) {
if (!isset(self::$_Counters['C'][$Key])) {
self::$_Counters['C'][$Key] = 1;
}
$Class = ['ATime' => LOG_DEBUG, 'RTime' => LOG_DEBUG, 'ACalls' => LOG_DEBUG, 'RCalls' => LOG_DEBUG, 'TimePerCall' => LOG_DEBUG];
$Call['RTime'] = round($Value / $Call['Performance']['Summary']['Time'] * 100, 2);
$Call['RCalls'] = round(self::$_Counters['C'][$Key] / $Call['Performance']['Summary']['Calls'] * 100, 2);
$Call['ATime'] = round($Value);
$Call['ACalls'] = self::$_Counters['C'][$Key];
$Call['TimePerCall'] = round($Value / self::$_Counters['C'][$Key], 2);
if (isset($Call['Alerts']['Yellow'])) {
foreach ($Call['Alerts']['Yellow'] as $Metric => $Limit) {
示例2: d
function d()
{
if (F::Environment() != 'Production' or PHP_SAPI == 'cli') {
call_user_func_array(['F', 'Dump'], func_get_args());
}
return func_get_arg(2);
}
示例3: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 8.x
*/
setFn('Do', function ($Call) {
if (is_array($Call['Project']['Hosts'][F::Environment()])) {
$Hosts = $Call['Project']['Hosts'][F::Environment()];
} else {
$Hosts = [$Call['Project']['Hosts'][F::Environment()]];
}
// Select Default Host
if (isset($_SERVER['HTTP_HOST'])) {
if (in_array($_SERVER['HTTP_HOST'], $Hosts)) {
$Call['HTTP']['Host'] = $_SERVER['HTTP_HOST'];
}
}
if (isset($Call['HTTP']['Host'])) {
F::Log('Host is determined: *' . $Call['HTTP']['Host'] . '*', LOG_INFO);
} else {
$Call['HTTP']['Host'] = $Hosts[0];
F::Log('Host is not determined, default selected', LOG_WARNING);
}
if (isset($Call['Project']['Active Hosts'][$Call['HTTP']['Host']])) {
$Call = F::Merge($Call, $Call['Project']['Active Hosts'][$Call['HTTP']['Host']]);
F::Log('Active host loaded: *' . $Call['HTTP']['Host'] . '*', LOG_INFO);
}
return $Call;
示例4: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 8.x
*/
setFn('Do', function ($Call) {
F::Log('CLI Interface Started', LOG_NOTICE);
$Call = F::Hook('beforeInterfaceRun', $Call);
$Call['HTTP']['IP'] = F::Live($Call['HTTP']['IP'], $Call);
if (isset($Call['Project']['Hosts'][F::Environment()])) {
$Call['HTTP']['Host'] = $Call['Project']['Hosts'][F::Environment()];
}
$Call['HTTP']['Proto'] = 'https';
$Call['HTTP']['URL'] = '/';
if (isset($Call['Skip Run'])) {
F::Log('Run Skipped, because ' . $Call['Skip Run'], LOG_INFO);
} else {
F::Log($Call['Service'] . ':' . $Call['Method'] . ' started', LOG_NOTICE);
$Call = F::Apply($Call['Service'], $Call['Method'], $Call);
}
$Call = F::Hook('afterInterfaceRun', $Call);
if (is_array($Call) && isset($Call['Output'])) {
F::Run('IO', 'Write', $Call, ['Storage' => 'Output', 'Where' => $Call['Service'] . ':' . $Call['Method'], 'Data' => $Call['Output']]);
if (isset($Call['Failure']) && $Call['Failure']) {
$Call['Return Code'] = 1;
}
}
F::Log('CLI Finished', LOG_NOTICE);
示例5: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description Exec Parslet
* @package Codeine
* @version 6.0
*/
setFn('Parse', function ($Call) {
foreach ($Call['Parsed'][2] as $IX => $Match) {
$Root = simplexml_load_string('<root ' . $Call['Parsed'][1][$IX] . '></root>');
$Environment = isset($Root->attributes()->eq) ? (string) $Root->attributes()->eq : null;
if ($Environment == F::Environment()) {
$Outer = $Match;
} else {
$Outer = '';
}
$NotEnvironment = isset($Root->attributes()->neq) ? (string) $Root->attributes()->neq : null;
if ($NotEnvironment !== null) {
if ($NotEnvironment == F::Environment()) {
$Outer = '';
} else {
$Outer = $Match;
}
}
$Call['Output'] = str_replace($Call['Parsed'][0][$IX], $Outer, $Call['Output']);
}
return $Call;
});
示例6: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 8.x
*/
setFn('Run', function ($Call) {
$Script = F::loadOptions($Call['Run'], null, [], 'Scripts');
$VCall = $Call;
$VCall['Environment'] = F::Environment();
foreach ($Script as $Run) {
$VCall = F::Live($Run, $VCall);
}
$Call['Output']['Content'] = [$VCall];
return $Call;
});
示例7: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 8.x
*/
setFn('Make', function ($Call) {
// FIXME Templatize
$Call['Options']['id'] = $Call['ID'];
$Code = '';
if (isset($Call['DNT Support']) && F::Run('System.Interface.HTTP.DNT', 'Detect', $Call)) {
$Code = '<!-- Do Not Track enabled. Yandex Metrics supressed. -->';
} else {
if (F::Environment() == 'Production') {
$Code = '<!-- Yandex.Metrika counter --><script type="text/javascript">(function (d, w, c) { (w[c] = w[c] || []).push(function() { try { w.yaCounter' . $Call['Options']['id'] . ' = new Ya.Metrika({id:' . $Call['Options']['id'] . ', webvisor:true, clickmap:true, trackLinks:true, accurateTrackBounce:true, trackHash:true}); } catch(e) { } }); var n = d.getElementsByTagName("script")[0], s = d.createElement("script"), f = function () { n.parentNode.insertBefore(s, n); }; s.type = "text/javascript"; s.async = true; s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js"; if (w.opera == "[object Opera]") { d.addEventListener("DOMContentLoaded", f, false); } else { f(); } })(document, window, "yandex_metrika_callbacks");</script><noscript><div><img src="//mc.yandex.ru/watch/' . $Call['Options']['id'] . '" style="position:absolute; left:-9999px;" alt="" /></div></noscript><!-- /Yandex.Metrika counter -->';
}
}
return $Code;
});
示例8: array_pop
$ID = array_pop($LocaleParts);
$Asset = implode('.', $LocaleParts);
$Asset = strtr($Asset, '.', '/');
$NewLocales = F::Run('IO', 'Read', ['Storage' => 'Locale', 'Scope' => $Asset . '/Locale/' . $Call['Locale'], 'Where' => $ID]);
$Locales[$Locale] = [];
if (is_array($NewLocales)) {
$NewLocales = array_reverse($NewLocales);
foreach ($NewLocales as $NewLocale) {
$Locales[$Locale] = F::Merge($Locales[$Locale], $NewLocale);
}
} else {
F::Log('Locale ' . $Locale . ' not loaded', LOG_NOTICE);
}
}
if (($Replace = F::Dot($Locales[$Locale], $Token)) !== null) {
if (is_scalar($Replace)) {
$Match = $Replace;
}
} else {
F::Log('Unresolved locale *' . $Match . '*', LOG_WARNING);
if (F::Environment() === 'Development') {
$Match = '<span class="nl">' . $Match . '</span>';
} else {
$Match = '';
}
}
}
$Call['Output'] = str_replace($Call['Parsed'][0], $Call['Parsed'][1], $Call['Output']);
}
return $Call;
});
示例9: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 8.x
*/
setFn('Do', function ($Call) {
$Call['Layouts'][] = ['Scope' => 'Server', 'ID' => 'Benchmark'];
$Call = F::Hook('beforeBenchmark', $Call);
$Call['Overall'] = 0;
foreach ($Call['Benchmark']['Modules'] as $BenchmarkName => $BenchmarkCall) {
$Rate = round(F::Run('Server.Benchmark.' . $BenchmarkName, 'Test', $BenchmarkCall) * $BenchmarkCall['Weight'], 2);
$Results[] = [$BenchmarkName, $Rate];
$Call['Overall'] += $Rate;
}
$Call['Output']['Overall'][] = $Call['Overall'];
$Call['Output']['Results'][] = ['Type' => 'Table', 'Value' => $Results];
$Call = F::Hook('afterBenchmark', $Call);
return $Call;
});
setFn('Send', function ($Call) {
$Result = F::Run('IO', 'Write', ['Storage' => 'Web', 'Output Format' => 'Formats.JSON', 'Where' => ['ID' => 'https://codeine-framework.org/benchmarks'], 'Data' => ['Host' => $Call['HTTP']['Host'], 'Score' => $Call['Overall'], 'Environment' => F::Environment(), 'Version' => $Call['Benchmark']['Version']]])[0];
$Call['Output']['Top'][] = $Result['Your'];
$Call['Output']['Total'][] = $Result['Total'];
return $Call;
});