Skip to content

Instantly share code, notes, and snippets.

<?php
class MathCase extends PHPUnit_Framework_TestCase
{
public function testAddition()
{
$this->assertEquals(1+1, 2);
}
}
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
doctrine_mongo_db:
server: mongodb://localhost:27017
default_database: mybundle_%kernel.environment%
options:
connect: true
metadata_cache_driver: array
mappings:
MyBundle: ~
<?php
$xmlBuilder = new XmlBuilder();
$xmlBuilder->root('notice')
->addAttribute('version', 2)
->addNode('api-key', 'apikeuvalue')
->addNode('commands')
->addNode('hello')
->addNode('execute', 'build --all')
->end()
@dator-zz
dator-zz / credit.php
Created February 2, 2011 10:54
Validate a credit card
<?php
function validate_creditcard ($creditcard) {
$creditcard = str_split(trim($creditcard));
foreach ($creditcard as $key => $number) {
if (!($key % 2)) {
$creditcard[$key] = $number * 2;
}
}
<?php
namespace Application\HelloBundle\Entity;
/**
* @orm:Entity
*/
class Channel
{
/**
I tried to run :
php app/console doctrine:database:drop
But i get this error:
[InvalidArgumentException]
Could not find any configured connections
Here is my configuration( DBAL )
@dator-zz
dator-zz / gist:769463
Created January 7, 2011 13:45
Git command to show an ordered list of a repository contributors
git log --pretty=format:%aN | sort | uniq -c | sort -rn
@dator-zz
dator-zz / Company.php
Created December 29, 2010 12:17
Custom user form for UserBundle
<?php
namespace Application\MyBundle\Document;
use Application\FOS\UserBundle\Model\User;
/**
* @mongodb:Document(
* collection="company",
* repositoryClass="Application\MyBundle\Document\CompanyRepository"
@dator-zz
dator-zz / gist:758389
Created December 29, 2010 10:12
textmate snippet, Symfony2 entities/documents getter/setter
/**
* Set $1
* @return null
*/
public function set${1/./\u$0/}(\$$1)
{
\$this->${1/./\l$0/} = \$${1/./\l$0/};
}
/**