This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Ecommerce\V1\Rest\Catalog; | |
class CatalogEntity | |
{ | |
public $id; | |
public $name; | |
public $description; | |
public $picture; | |
public $price; | |
public $quantity; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get the router adapters installed | |
*/ | |
public function getRouterAdapters() | |
{ | |
$adapters = []; | |
if (class_exists('Aura\Router\Router')) { | |
$adapters[] = [ 'Zend\Expressive\Router\Aura' ]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Experimantal plugin manager complaint with ContainerInterface with options support | |
* using the optional Interface rule of PHP | |
*/ | |
use Interop\Container\ContainerInterface; | |
class PluginManager implements ContainerInterface | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Sign a file with a private key using OpenSSL | |
# Encode the signature in Base64 format | |
# | |
# Usage: sign <file> <private_key> | |
# | |
# NOTE: to generate a public/private key use the following commands: | |
# | |
# openssl genrsa -aes128 -passout pass:<passphrase> -out private.pem 2048 | |
# openssl rsa -in private.pem -passin pass:<passphrase> -pubout -out public.pem |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Verify and install composer from https://getcomposer.org/installer | |
me=`basename "$0"` | |
if [[ $# -eq 0 ]] ; then | |
echo "Usage: $me <hash>" | |
echo 'where <hash> is the hash value of the installer to verify' | |
exit 1 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Decrypt a file generated with the command line: | |
* openssl enc -aes-256-cbc -in file-to-encrypt -out encrypted-file -k password | |
* | |
* To decrypt: | |
* php decrypt.php encrypted-file password decrypted-file | |
* | |
* NOTE: this script has been tested with OpenSSL v.1.1, for old version | |
* please check if you need to use MD5 instead of SHA256 in EVP_BytesToKey() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); |