This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
trait Loggable { | |
public function log($event) { | |
printf("Event: '%s', source: '%s'\n", | |
event, get_class($this)); | |
} | |
} | |
class User { | |
use Loggable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function dereference() { | |
$arr = ['php', '5.4', 'looks', 'nice']; | |
return $arr; | |
} | |
printf("%s - %s\n", dereference()[1], dereference()[3]); | |
// will echo: | |
// 5.4 - nice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function closureTest(callable $callback) { | |
printf("Look, I'm running callback! '%s'\n", $callback()); | |
} | |
closureTest(function() { return 'foo'; }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project name="Symfony2 project" default="build"> | |
<target name="build" depends="pull, vendors, cache, assetic, assets"> | |
<echo message="Symfony2 project"/> | |
</target> | |
<macrodef name="git"> | |
<attribute name="command" /> | |
<attribute name="dir" default="" /> | |
<element name="args" optional="true" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\Validator\Constraints as Assert | |
class ObjectRecievingMultiplieFilesFromForm | |
{ | |
/** | |
* @Assert\All({ | |
* @Assert\File(mimeTypes={"application/vnd.ms-excel", "application/vnd.ms-office"}) | |
* }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
GIT_DIR=/home/wojciech.sznapka/htdocs/real.arch.sznapka.xsdev.pl/ | |
echo "*** Running $0" | |
echo "*** Resetting working copy of real.arch.sznapka.xsdev.pl" | |
(cd $GIT_DIR | |
git --git-dir=.git/ reset --hard HEAD > /dev/null) | |
echo "*** Updating real.arch.sznapka.xsdev.pl" | |
(cd $GIT_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install gender http://www.php.net/manual/en/book.gender.php | |
sudo apt-get install libpcre3-dev | |
sudo pecl install gender | |
# generate data | |
mkdir ~/gender | |
sudo pear run-scripts pecl/gender | |
# eneble module | |
echo 'extension=gender.so' >> /etc/php5/cli/php.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @View() | |
* @Get("/leads/{id}") | |
* @ParamConverter("offer", class="SomeBundle:Offer\OfferLead") | |
*/ | |
public function getLeadAction(OfferLead $lead) | |
{ | |
return array('lead' => $lead); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Acme\Example\Tests; | |
use Symfony\Component\Console\Input\ArrayInput; | |
use Symfony\Bundle\FrameworkBundle\Console\Application; | |
use Doctrine\DBAL\Driver\PDOSqlite\Driver as PDOSqliteDriver; | |
require_once(__DIR__ . IsolatedTestsTrait::$kernelRootDir . '/AppKernel.php'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* $Id$ */ | |
set_include_path(get_include_path() . ':' . __DIR__ . '/../lib'); | |
include 'SabreAMF/Client.php'; //Include the client scripts | |
spl_autoload_register(function($classname) { | |
$filename = str_replace(array('_', '\\'), DIRECTORY_SEPARATOR, $classname) . '.php'; | |
include $filename; | |
}); |