Skip to content

Instantly share code, notes, and snippets.

<?php
spl_autoload_register(function ($name) {
// $exp will be the name of the class without the \with\traitname part => array_splice
$exp = explode("\\", $name);
// serach from end
$index = array_search("with", array_reverse($exp, true));
if (!$index || $index - 1 == count($exp)) // also fail when value is 0
return false;
@brtriver
brtriver / update2.2to2.3.md
Last active December 18, 2015 01:29
Symfony2.3にあげるときにはまったこと

Symfony を 2.2 から 2.3 にアップしたときのメモ

  • updateするときのお話。新規でcreate-projectするなら何も困らない

  • php composer.phar update する前に以下をチェック

  • composer.jsonの修正

  • http://symfony.com/blog/symfony-2-3-0-the-first-lts-is-now-available

  • キャッシュファイルは事前にrmしておく

  • icuが4.4以上でないと怒られるので、事前にインストールしているicuのバージョンをチェックしておくこと

  • composer.jsonでバージョン指定すれば回避可能 http://php-sql-gdgd.jugem.jp/?eid=104

@tanakahisateru
tanakahisateru / gist:1344162
Created November 7, 2011 04:18
PHP5.4 configure with MacPorts besides existing PHP
./configure \
--prefix=/opt/local/php/5.4 \
--bindir=/opt/local/bin \
--with-config-file-path=/opt/local/php/5.4/etc \
--with-config-file-scan-dir=/opt/local/php/5.4/var/db \
--mandir=/opt/local/php/5.4/share/man \
--infodir=/opt/local/php/5.4/share/info \
--program-suffix=-5.4 \
--with-apxs2=/opt/local/apache2/bin/apxs \
--enable-pdo \
@predominant
predominant / ubuntu-1104-nginx-base.sh
Created October 5, 2011 15:19
Install Ubuntu 11.04 Nginx based web server with PHP-FPM, MySQL and MongoDB
#!/bin/bash
###
#
# Copyright (c) 2011 Cake Development Corporation (http://cakedc.com)
#
# Ubuntu 11.04 based web server installation script
# Run this by executing the following from a fresh install of Ubuntu 11.04 server:
#
# bash -c "$(curl -fsSL https://raw.github.com/gist/1264701)" <mysqlPassword>
@Herzult
Herzult / CustomizableFileLocator.php
Created May 23, 2011 12:38
POC of a customizable file locator (ease the share of a Symfony project)
<?php
/**
* File locator that first look for a "filename.local.ext" when the name of the
* file to locate matches the "filename.customizable.ext" pattern, then it look
* for a "filename.ext" file.
*/
class CustomizableFileLocator extends FileLocator
{
/**
@weaverryan
weaverryan / Basic Twig
Created October 28, 2010 23:39
Here's a small victory for a Twig noob
<div id="breadcrumbs">
{% for breadcrumb in breadcrumbs %}
{% if not loop.last %}
{{ breadcrumb | raw }} {{ breadcrumbs.separator | raw }}
{% else %}
<strong>{{ breadcrumb.label }}</strong>
{% endif %}
{% endfor %}
</div>
app.config
templating:
path:
- "%kernel.root_dir%/../views/%%bundle%%/%%controller%%/%%name%%%%format%%.%%renderer%%"
- "%kernel.root_dir%/../src/Symfony/Bundle/%%bundle%%/Resources/views/%%controller%%/%%name%%%%format%%.%%renderer%%"

XHProf 導入

はじめに

PHP アプリのボトルネックの分析に XHProf を使う。

XHProf は PECL 拡張として提供されている。