Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan Weaver weaverryan

View GitHub Profile
View ProjectConfiguration.class.php
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
$this->setupProjectPlugins();
}
/**
* Responsible for initiating any plugins and pointing vendor plugins
* to the "vendor" subdirectory
View Symfony2 CMF Symfony Live CFP
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 Oct 28, 2010
Here's a small victory for a Twig noob
View Basic Twig
<div id="breadcrumbs">
{% for breadcrumb in breadcrumbs %}
{% if not loop.last %}
{{ breadcrumb | raw }} {{ breadcrumbs.separator | raw }}
{% else %}
<strong>{{ breadcrumb.label }}</strong>
{% endif %}
{% endfor %}
</div>
View Method matching using regex
<?php
$start = microtime(true);
$limit = 10000;
for ($i = 0; $i < $limit; $i++)
{
preg_match('#^(GET|HEAD)$#x', 'GET');
preg_match('#^(GET|HEAD)$#x', 'PUT');
}
View Method matching using in_array()
<?php
$start = microtime(true);
$limit = 10000;
for ($i = 0; $i < $limit; $i++)
{
preg_match('#^(GET|HEAD)$#x', 'GET');
preg_match('#^(GET|HEAD)$#x', 'PUT');
View Method matching using in_array()
<?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 Dec 4, 2010
Offers a way to save files as a cleaned, unique version of the original filename in symfony1
View wfValidatedFileNamer
<?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 Jan 3, 2011
WIP Symfony2 View Documentation with notes
View view.rst

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 Mar 24, 2011
very messy autoloader benchmark
View gist:884439
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 Mar 28, 2011
A proposed change to the new form factory's builder creation (to make easier)
View symfony-form-factory-create.php
<?php
// current
$form = $this->get('form.factory')->create(
new ProductType(),
'my_form',
array('csrf_protection' => false, 'data_class' => 'Acme\StoreBundle\Entity\Product')
);
You can’t perform that action at this time.