Skip to content

Instantly share code, notes, and snippets.

View pghoratiu's full-sized avatar
🏠
Working from home

Gabriel Horatiu Petchesi pghoratiu

🏠
Working from home
  • Prolix SRL
  • Oradea, Romania
  • 10:20 (UTC +03:00)
  • X @pghoratiu
View GitHub Profile
@pghoratiu
pghoratiu / gist:3229011
Created August 1, 2012 17:26
Symfony1 warmup cache from CLI
<?php
require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
if (1) {
$configuration = ProjectConfiguration::getApplicationConfiguration('backend', 'prod', false);
} else {
$configuration = ProjectConfiguration::getApplicationConfiguration('backend', 'dev', false);
}
@pghoratiu
pghoratiu / symfony errors in form.php
Created March 21, 2012 16:14
Retrieve errors from the from error schema and print it out.
<?php
$msg = '';
foreach( $form->getFormFieldSchema( ) as $name => $formField )
{
if( $formField->getError( ) != "" )
{
$msg = $name . " : " . $formField->getError( );
}
}
@pghoratiu
pghoratiu / search.php
Created March 20, 2012 15:36
Recursive search for files using PHP iterator
<?php
search_files('/home/gabi/test/', '.png');
function search_files($dir, $extension) {
$extension_length = strlen($extension);
$rit = new RecursiveDirectoryIterator($dir);
foreach(new RecursiveIteratorIterator($rit) as $file) {
if(strcasecmp(substr($file, -$extension_length), $extension) == 0) {
echo "$file\n";
@pghoratiu
pghoratiu / tree walk.php
Created April 18, 2011 18:49
tree walk in php
/**
* Returneaza rezultatul sub forma unui array flat pe care poti
* sa-l transformi usor intr-un string
*/
tree_walk_recursive($src)
{
$result = array();
foreach($src as $key => $value)
{