Skip to content

Instantly share code, notes, and snippets.

View shin1x1's full-sized avatar
😀

Masashi Shinbara shin1x1

😀
View GitHub Profile
<?php
require __DIR__.'/vendor/autoload.php';
class Foo
{
/**
* @var string
*/
protected $message;
<?php
require __DIR__.'/vendor/autoload.php';
class Hello
{
/**
*
*/
public function greet()
{
<?php
require __DIR__.'/vendor/autoload.php';
interface Greetable
{
public function greet();
}
class Hello implements Greetable
{
<?php
var_dump(get_defined_constants());
var_dump(get_declared_classes());
var_dump(get_declared_interfaces());
var_dump(get_declared_traits());
var_dump(get_defined_functions());
var_dump(get_defined_vars());
var_dump(get_included_files());
var_dump(get_required_files());
var_dump(get_loaded_extensions());
<?php
// session
ini_set('session.save_handler','memcached');
ini_set('session.save_path','PERSISTENT=abc localhost:11211');
//ini_set('session.save_path','localhost:11211');
ini_set('memcached.sess_consistent_hash', '1');
session_start();
if (empty($_SESSION['count'])) {
$_SESSION['count'] = 0;
<?php
class Foo
{
protected $name = '';
public function __construct($name)
{
$this->name = $name;
}
@shin1x1
shin1x1 / guzzle3_send_event_listener_sample.php
Created July 25, 2014 01:10
guzzle3_send_event_listener_sample
<?php
use Guzzle\Http\Client;
use Guzzle\Http\Curl\CurlMultiInterface;
use Symfony\Component\EventDispatcher\Event;
require_once __DIR__ . '/vendor/autoload.php';
$client = new Client();
$client->getEventDispatcher()->addListener(CurlMultiInterface::MULTI_EXCEPTION, function(Event $e) {
throw new Exception();
@shin1x1
shin1x1 / Vagrantfile
Created October 31, 2014 04:59
プロビジョン済 Box を起動する Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
end
@shin1x1
shin1x1 / install.md
Last active August 29, 2015 14:08
プロビジョン済 Box の利用方法

仮想マシンを起動中なら、破棄しておく

$ cd /path/to/phpci_handson
$ vagrant destroy -f

backup ディレクトリを USB メモリからコピー

@shin1x1
shin1x1 / gist:e979bf76c305513c7089
Created March 17, 2015 02:37
CSRF Protection Filter for Laravel 4 with AngularJS
<?php
Route::filter(
'csrf',
function () {
$token = Request::header('X-XSRF-TOKEN');
if (empty($token)) {
$token = Input::get('_token');
}