In this experiment, I tested the execution time of the script Zend\bench.php available in the PHP socurce code. I tested the latest PHP versions available, as follows:
- PHP 7.1.32
- PHP 7.2.22
- PHP 7.3.9
- PHP 7.4RC1
<?php | |
// include the ZF2 library | |
use Zend\Filter\Encrypt; | |
if (!isset($argv[1]) or !isset($argv[2])) { | |
die("Usage: " . basename(__FILE__) . " <file_to_encrypt> <encryption_key>\n"); | |
} | |
if (!file_exists($argv[1])) { | |
die("The file {$argv[1]} specified doesn't exist\n"); |
<?php | |
use Zend\Stratigility\MiddlewarePipe; | |
use Zend\Diactoros\Server; | |
require 'vendor/autoload.php'; | |
$app = new MiddlewarePipe(); | |
$server = Server::createServer($app, $_SERVER, $_GET, $_POST, $_COOKIE, $_FILES); | |
// Injected for all the URL |
// config/autoload/global.php | |
// ... | |
'router' => array( | |
'routes' => array( | |
'oauth' => array( | |
'options' => array( | |
'route' => '/oauth', | |
), | |
), |
<?php | |
// Testing md5 vs. preg_replace_callback() | |
$execPreg = 0; | |
$execMd5 = 0; | |
for ($i=0; $i<100000; $i++) { | |
$name = randomName(10); | |
$start = microtime(true); | |
$result = preg_replace_callback( |
RewriteEngine On | |
# The following rule tells Apache that if the requested filename | |
# exists, simply serve it. | |
RewriteCond %{REQUEST_FILENAME} -s [OR] | |
RewriteCond %{REQUEST_FILENAME} -l [OR] | |
RewriteCond %{REQUEST_FILENAME} -d | |
RewriteRule ^.*$ - [NC,L] | |
# The following rewrites all other queries to index.php. The | |
# condition ensures that if you are using Apache aliases to do |
In this experiment, I tested the execution time of the script Zend\bench.php available in the PHP socurce code. I tested the latest PHP versions available, as follows:
<?php | |
$http = new swoole_http_server("127.0.0.1", 9501); | |
$http->on("start", function ($server) { | |
var_dump($server); | |
echo "Swoole http server is started at http://127.0.0.1:9501\n"; | |
}); | |
$http->on("request", function ($request, $response) { | |
var_dump($request); |
<?php | |
// APIs for overriding functions and methods of classes | |
override_class_function(string $class, string $method, Closure $callback); | |
override_function(string $function, Closure $callback); | |
call_orginal_function(array $params); | |
// Example of usage override_function() | |
override_function('curl_exec', function(){ | |
$params = func_get_args(); | |
echo "--- BEFORE ---"; |
I executed the Zend\bench.php file using PHP 7.4.7 and PHP 8 alpha2.
I used a CPU Intel i9-8950HK at 2.90GHz with 32GB RAM running Ubuntu 18.04.4 LTS.
I compiled PHP 8 alpha2 using the official php.net source and installed in /opt/php/php8
. I used the following configure options:
./configure --prefix=/opt/php/php8 --enable-opcache --with-zlib --enable-zip --enable-json --enable-sockets --without-pear
I executed the Zend\bench.php file using PHP 7.4.10 and PHP 8 beta4.
I used a CPU Intel i9-8950HK at 2.90GHz with 32GB RAM running Ubuntu 18.04.4 LTS.
I compiled PHP 8 beta4 using the official php.net source and installed in /opt/php/php8
. I used the following options:
./configure --prefix=/opt/php/php8 --enable-opcache --with-zlib --enable-zip --enable-json --enable-sockets --without-pear