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
RPC: GET /getalbum | |
Request | |
{ "id" : 1 } | |
OK Response (200): | |
{ | |
"id" : 1, | |
"artist" : { | |
"name" : "Metallica", | |
"history" : "Simply the best heavy metal band ever!", | |
"genre" : "Heavy metal, Hard rock, Speed metal, Thrash metal" |
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
CREATE TABLE post ( | |
id int(11) NOT NULL auto_increment, | |
title varchar(100) NOT NULL, | |
content TEXT NOT NULL, | |
user_id int(11), | |
category_id int(11), | |
publish_date DATETIME, | |
PRIMARY KEY (id) | |
); |
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 | |
// 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"); |
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 | |
// The libxml entity loader is disabled by default | |
// even setting the libxml_disable_entity_loader to false doesn't works! | |
// | |
// @see http://uk3.php.net/manual/en/function.libxml-disable-entity-loader.php | |
// @see http://stackoverflow.com/a/10213239 | |
$dir = __DIR__; | |
$content = 'This is a remote content!'; | |
file_put_contents('content.txt', $content); |
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 | |
include '/path/to/vendor/autoload.php'; | |
use ZendOAuth\Token\Access as AccessToken; | |
use Zend\Http\Request; | |
use Zend\Http\Response; | |
$config = array( | |
'callbackUrl' => 'http://example.com/callback.php', | |
'siteUrl' => 'http://twitter.com/oauth', |
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 | |
namespace Test\V1\Rpc\Test; | |
use Zend\Mvc\Controller\AbstractActionController; | |
use ZF\ContentNegotiation\ViewModel; | |
use ZF\Hal\Entity; | |
use ZF\Hal\Link\Link; | |
class TestController extends AbstractActionController | |
{ |
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 | |
set_include_path('path/to/zf1/library'); | |
require_once 'Zend/Db.php'; | |
$db = Zend_Db::factory('Pdo_Mysql', array( | |
'host' => '127.0.0.1', | |
'username' => '', | |
'password' => '', | |
'dbname' => 'test' | |
)); |
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 | |
// route configuration, for instance in a module.config.php | |
// ... | |
'home' => array( | |
'type' => 'segment', | |
'options' => array( | |
'route' => '/[:lang/]', | |
'defaults' => array( | |
'__NAMESPACE__' => 'Application\Controller', | |
'controller' => 'Index', |
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 | |
// Benchmark the Pbkdf2 iteration (10'000 = 50 ms, using an Intel i5 CPU at 2) | |
use Zend\Crypt\Key\Derivation\Pbkdf2; | |
use Zend\Math\Rand; | |
$salt = Rand::getBytes(32); | |
$pass = 'this is the password of the user'; | |
$start = microtime(true); |
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
// config/autoload/global.php | |
// ... | |
'router' => array( | |
'routes' => array( | |
'oauth' => array( | |
'options' => array( | |
'route' => '/oauth', | |
), | |
), |