Skip to content

Instantly share code, notes, and snippets.

@SuoXC
SuoXC / Facade.php
Last active August 1, 2017 01:34
simple service locator + Facade(like in Laravel) implementation
<?php
class Facade{
private static $service = null;
public static function getKey(){
return 'world';
}
public static function __callstatic($method,$args){
if(!isset(self::$service)){
self::$service = ServiceLocator::getInstance()->getService(self::getKey());
}
@SuoXC
SuoXC / request_parallely.php
Created November 20, 2016 15:45
use php curl_multi_* to perform http requests
<?php
interface HandleIterator {
public function getNextHandle();
public function dataCallback($data);
}
class IndexHandleIterator implements HandleIterator{
private $curl;
private $count;
public function __construct(){
$this->curl = curl_init("http://localhost/index.php");