Skip to content

Instantly share code, notes, and snippets.

@CHH
CHH / compile_flags.txt
Created March 7, 2012 12:56 — forked from xenji/compile_flags.txt
Compile flags for xcache and memcache for php5.4.0
CFLAGS="-D_REENTRANT -D_THREAD_SAFE -O3 -pipe -pthread" CXXFLAGS="-D_REENTRANT -D_THREAD_SAFE -O3 -pipe -pthread" ./configure
@CHH
CHH / cli.php
Created May 18, 2012 10:13
Run something only when the file is invoked on the command line.
<?php
# Some regular library code, which can be used by including
# the file.
class Foo
{
# Do not use a global function, because you get an error
# if you try to redefine it.
static function __main()
{
@CHH
CHH / server.php
Created May 30, 2012 06:13
Einhorn PHP Example
<?php
declare(ticks = 1);
# Einhorn sends a "USR2" signal to our server process
# in case the server shuts down.
pcntl_signal(SIGUSR2, function() {
fwrite(STDERR, "Worker shutting down...\n");
exit(0);
});
@CHH
CHH / gist:4086320
Created November 16, 2012 10:40
XDebug compile error on 5.5.0alpha1
/var/tmp/php-build/source/xdebug-master/xdebug.c:567:30: warning: incompatible pointer types assigning to 'void (*)(zend_execute_data *, int)' from 'void (*)(zend_execute_data *, struct _zend_fcall_info *, int)' [-Wincompatible-pointer-types]
xdebug_old_execute_internal = zend_execute_internal;
^ ~~~~~~~~~~~~~~~~~~~~~
/var/tmp/php-build/source/xdebug-master/xdebug.c:568:24: warning: incompatible pointer types assigning to 'void (*)(zend_execute_data *, struct _zend_fcall_info *, int)' from 'void (zend_execute_data *, int)' [-Wincompatible-pointer-types]
zend_execute_internal = xdebug_execute_internal;
^ ~~~~~~~~~~~~~~~~~~~~~~~
/var/tmp/php-build/source/xdebug-master/xdebug.c:704:24: warning: incompatible pointer types assigning to 'void (*)(zend_execute_data *, struct _zend_fcall_info *, int)' from 'void (*)(zend_execute_data *, int)' [-Wincompatible-pointer-types]
zend_execute_internal = xdebug_old_execute_internal;
@CHH
CHH / silex_cli.php
Created December 7, 2012 09:02
Silex for the CLI
<?php
$app = new Application;
$app->match('greet [--yell] <name>', function($name, $options) {
$message = "Hello $name!";
if (isset($options['yell'])) {
$message = strtoupper($message);
}
@CHH
CHH / composer.json
Created December 19, 2012 16:24
React Promise + libuv fun!
{
"require": {
"react/promise": "*@dev"
}
}
@CHH
CHH / struct.php
Last active December 10, 2015 20:59
A simple struct class for PHP.
<?php
abstract class Struct implements \ArrayAccess
{
function __construct($properties = array())
{
$this->init();
foreach ($properties as $property => $value) {
$this->$property = $value;
@CHH
CHH / README.md
Last active December 15, 2015 02:39
Configuring a Heroku Buildpack via the composer.json?

Unofficial Heroku Buildpack for PHP

This Heroku Buildpack adds more advanced support for PHP.

  • Runs apps written for both PHP 5.4 and 5.3
  • Supports Composer dependencies and caching of the vendor/ directory for fast deploys
  • Simple configuration via the project's composer.json
  • Stable and fast setup using NGINX, PHP-FPM and Zend Optimizer Plus
autoconf
bash
cabextract
cloog-ppl015
cmake
ctags
fortune
freetype
gawk
gdbm
@CHH
CHH / buildpack.sh
Created August 28, 2013 12:52
How to test the unstable branch of the PHP buildpack.
heroku config:set BUILDPACK_URL=git://github.com/CHH/heroku-buildpack-php#development
git commit -m "Rebuild" --allow-empty
git push heroku master
heroku open