forked from php-pm/php-pm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
62 lines (55 loc) · 1.48 KB
/
functions.php
File metadata and controls
62 lines (55 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace PHPPM;
/**
* Adds a file path to the watcher list of PPM's master process.
*
* If you have a custom template engine, cache engine or something dynamic
* you probably want to call this function to let PPM know,
* that you want to restart all workers when this file has changed.
*
* @param string $path
*/
function register_file($path)
{
ProcessSlave::$slave->registerFile($path);
}
/**
* Dumps information about a variable into your console output.
*
* @param mixed $expression The variable you want to export.
* @param mixed $_ [optional]
*/
function console_log($expression, $_ = null)
{
\ob_start();
\var_dump(...\func_get_args());
\file_put_contents('php://stderr', \ob_get_clean() . PHP_EOL, FILE_APPEND);
}
/**
* Checks that PCNTL extension is installed and loaded in this installation.
*
* @return bool
*/
function pcntl_installed()
{
return \extension_loaded('pcntl');
}
/**
* Makes sure required PCNTL functions aren't included in disable_functions.
*
* @return bool
*/
function pcntl_enabled()
{
$requiredFunctions = ['pcntl_signal', 'pcntl_signal_dispatch', 'pcntl_waitpid'];
$disabledFunctions = \explode(',', (string) \ini_get('disable_functions'));
$disabledFunctions = \array_map(function ($item) {
return \trim($item);
}, $disabledFunctions);
foreach ($requiredFunctions as $function) {
if (\in_array($function, $disabledFunctions)) {
return false;
}
}
return true;
}