Skip to content

Instantly share code, notes, and snippets.

<?php
namespace CHH;
trait MetaObject
{
protected static $__metaClass;
static function setMetaClass(MetaClass $metaClass)
{
@tortuetorche
tortuetorche / 01_OLD_GIST.md
Last active December 21, 2015 18:59
Finite Trait
@tortuetorche
tortuetorche / 01.FiniteStateMachine.README.md
Last active October 12, 2017 23:06
FiniteStateMachine Trait with Example.Add a DSL to the PHP Finite package, borrowed from the Ruby StateMachine gem.

FiniteStateMachine Trait

Add a DSL to the PHP Finite package, borrowed from the Ruby StateMachine gem.

Usage

In your Stateful Class, add the stateMachineConfig() method and call initStateMachine() method at initialization (__contruct() method).

Example

@tortuetorche
tortuetorche / README.md
Last active March 12, 2021 12:07
Compile and install runkit PHP PECL extension

Install runkit PHP PECL extension

On Ubuntu

sudo apt-get install gcc php-pear php5-dev
cd ~/Downloads
git clone https://github.com/zenovich/runkit.git
@tortuetorche
tortuetorche / 01.FiniteAuditTrail.README.md
Last active May 28, 2022 03:39
FiniteAuditTrail Trait For Laravel 4 with Example. Support for keeping an audit trail for any state machine, borrowed from the Ruby StateMachine audit trail gem.

FiniteAuditTrail Trait

Support for keeping an audit trail for any state machine, borrowed from the Ruby StateMachine audit trail gem. Having an audit trail gives you a complete history of the state changes in your model. This history allows you to investigate incidents or perform analytics, like: “How long does it take on average to go from state a to state b?”, or “What percentage of cases goes from state a to b via state c?”

Requirements

  1. PHP >= 5.4
  2. Laravel 4 framework
@tortuetorche
tortuetorche / INSTALL4Windows.md
Last active April 12, 2020 23:06
Redis for Windows as a Memcache successor for PHP applications and as a queue driver for Laravel

Install Redis as a service on Windows

Installation instructions

  1. Download and extract the last Redis version (2.8.4)
  2. Copy all extracted binaries to c:\redis\bin
  3. Create another folder at c:\redis\inst1
  4. Download and extract the RedisWatcher binaries from the 2.4 branch
  5. Run InstallWatcher.msi with administrator rights. This should create a Windows service called Redis watcher.
@tortuetorche
tortuetorche / 01_README.md
Last active June 11, 2016 21:17
Legacy browsers compatibility (like IE 8 and 9, Android 2.3, Safari 5...) for Turbolinks.replace() ⚠️ Alpha version ⚠️

⚠️ This gist has moved to its own Github repository

You can grab the code HERE 😼

@tortuetorche
tortuetorche / Select2.php
Last active May 28, 2021 10:41
Select2 v3.5 helpers for the WebDriver module of Codeception 2.1 (WIP)
<?php
namespace Helper;
// Select2 helpers for the jQuery based replacement for select boxes.
// See: http://select2.github.io/select2
// Author: Tortue Torche <tortuetorche@spam.me>
// License: MIT
//
// Installation:
// * Put this file in your 'tests/_support/Helper' directory
@tortuetorche
tortuetorche / CacheRepository.php
Last active September 11, 2015 18:03 — forked from tillkruss/Database.php
[Laravel 5.1] Use Redis PECL/HHVM extension
<?php
namespace App\Repositories;
use Illuminate\Cache\Repository;
class CacheRepository extends Repository
{
public function has($key)
{
@tortuetorche
tortuetorche / FiniteAuditTrailTrait.php
Created July 12, 2016 15:32
FiniteStateMachine and FiniteAuditTrail Traits for Laravel 5.1 (WIP)
<?php namespace App\Finite;
/**
* The FiniteAuditTrail Trait.
* This plugin, for the Finite package (see https://github.com/yohang/Finite), adds support for keeping an audit trail for any state machine.
* Having an audit trail gives you a complete history of the state changes in your stateful model.
* Prerequisites:
* 1. Install Finite package (https://github.com/yohang/Finite#readme)
* 2. Use FiniteStateMachine in your model (https://gist.github.com/tortuetorche/6365575)
* Usage: in your Stateful Class use this trait after FiniteStateMachine trait, like this "use FiniteAuditTrailTrait;".