Real time flushing in PHP on Nginx

Works perfectly on RunCloud’s Native Nginx Stack. @ini_set(‘zlib.output_compression’, 0); @ini_set(‘output_buffering’, ‘Off’); @ini_set(‘implicit_flush’, true); @ob_implicit_flush(1); @ob_end_clean(); header(‘Content-Encoding: none’); header(‘X-Accel-Buffering: no’);

Remove image sizes in WordPress

/** * Function to Remove image size. * @param [string] $size */ function remove_image_size_by_size($size) { $dimension = explode(‘x’, $size); global $_wp_additional_image_sizes; foreach ($_wp_additional_image_sizes as $key => $single) { if ($single[‘width’] == $dimension[0] && $single[‘height’] == $dimension[1]) { remove_image_size($key); break; }

Change default PHP CLI configuration on RunCloud

Runcloud allows you to change the PHP Settings for each application from their Web Panel. But if you’re like me who heavily uses the PHP-CLI then changing config from Web Panel won’t help you. The PHP configs from their Web

Fix CMD output when using shell_exec() from PHP

/** * Fix weird output encoding. */ function run_command($command) { $string = shell_exec($command); $string = mb_convert_encoding($string, ‘UTF-8’, ‘UTF-16LE’); return $string; } Source:

Get all system IPv4 addresses as array in PHP

/** * Get system ipv4 addresses. * Works on Linux only. * @return [array] */ function getSystemIPs() { $ips = shell_exec(‘hostname -I’); $ips = preg_split(‘/\s+/’, $ips, -1, PREG_SPLIT_NO_EMPTY); foreach ($ips as $ip) { if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE |