Composer: proc_open(): fork failed errors

If composer shows proc_open() fork failed on some commands: PHP Fatal error: Uncaught exception ‘ErrorException’ with message ‘proc_open(): fork failed – Cannot allocate memory’ in phar This could be happening because the VPS runs out of memory and has no Swap space enabled. free -m   total used free shared buffers cached Mem: 2048 357
Continue reading Composer: proc_open(): fork failed errors

PHP: percent-encoding aka URL encoding

Percent-encoding, also known as URL encoding, is a mechanism for encoding information in a Uniform Resource Identifier (URI) under certain circumstances. In PHP you have rawurlencode, rawurldecode for “raw” URL encoding as well as the urlencode and urldecode for the slightly different encoding that is used in the query (rather known as application/x-www-form-urlencoded where the
Continue reading PHP: percent-encoding aka URL encoding

PHP: check if SSL is being used

This method should also work on servers behind a load balancer: $isSecure = false;   if (isset($_SERVER[’HTTPS’]) && $_SERVER[’HTTPS’] == ‘on’) { $isSecure = true; } elseif (!empty($_SERVER[’HTTP_X_FORWARDED_PROTO’]) && $_SERVER[’HTTP_X_FORWARDED_PROTO’] == ‘https’ || !empty($_SERVER[’HTTP_X_FORWARDED_SSL’]) && $_SERVER[’HTTP_X_FORWARDED_SSL’] == ‘on’) {   $isSecure = true; }$isSecure = false; if (isset($_SERVER[‘HTTPS’]) && $_SERVER[‘HTTPS’] == ‘on’) { $isSecure =
Continue reading PHP: check if SSL is being used

Reflection in PHP

Reflection is generally defined as a program’s ability to inspect itself and modify its logic at execution time. In less technical terms, reflection is asking an object to tell you about its properties and methods, and altering those members (even private ones). In this lesson, we’ll dig into how this is accomplished, and when it
Continue reading Reflection in PHP