Skip to content

Instantly share code, notes, and snippets.

View weaverryan's full-sized avatar

Ryan Weaver weaverryan

View GitHub Profile
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
$this->setupProjectPlugins();
}
/**
* Responsible for initiating any plugins and pointing vendor plugins
* to the "vendor" subdirectory
Symfony Live CFP: State of the Symfony2 CMF project
===================================================
### Title: State of the Symfony2 CMF Project
### Level: Beginner
### Brief Description
Let's face it: managing content is hard. Issues such as versioning, asset
@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>
<?php
$start = microtime(true);
$limit = 10000;
for ($i = 0; $i < $limit; $i++)
{
preg_match('#^(GET|HEAD)$#x', 'GET');
preg_match('#^(GET|HEAD)$#x', 'PUT');
}
<?php
$start = microtime(true);
$limit = 10000;
for ($i = 0; $i < $limit; $i++)
{
preg_match('#^(GET|HEAD)$#x', 'GET');
preg_match('#^(GET|HEAD)$#x', 'PUT');
<?php
$start = microtime(true);
$limit = 10000;
for ($i = 0; $i < $limit; $i++)
{
in_array('GET', array('GET', 'HEAD'));
in_array('PUT', array('GET', 'HEAD'));
}
@weaverryan
weaverryan / wfValidatedFileNamer
Created December 4, 2010 16:04
Offers a way to save files as a cleaned, unique version of the original filename in symfony1
<?php
/**
* Offers a way to save files as a cleaned, unique version of the original filename.
*
* Use this as the 'validated_file_class' option on sfValidatorFile.
*
* Bad characters are replaced by the replaceCharacter string. Unique filenames
* are created by appending an increasing -# to the end of the basename
* of the uploaded file.
@weaverryan
weaverryan / view.rst
Created January 3, 2011 14:34
WIP Symfony2 View Documentation with notes

The View

For each request in Symfony2, the goal of the developer is always the same: to construct and return a Response object that represents the resource being requested. This is most obvious inside a controller, which almost always returns a Response object:

@weaverryan
weaverryan / gist:884439
Created March 24, 2011 02:32
very messy autoloader benchmark
require_once 'app/autoload.php';
$classes = array(
'Acme\\FakeBundle',
'Zend_Log',
'Zend_Fake_class',
'Symfony\\Component\\HttpFoundation\\Response',
'Symfony\\Bundle\\DoctrineBundle',
'Acme\\HelloBundle\\AcmeHelloBundle',
'Doctrine\\Foo',
@weaverryan
weaverryan / symfony-form-factory-create.php
Created March 28, 2011 12:58
A proposed change to the new form factory's builder creation (to make easier)
<?php
// current
$form = $this->get('form.factory')->create(
new ProductType(),
'my_form',
array('csrf_protection' => false, 'data_class' => 'Acme\StoreBundle\Entity\Product')
);