Skip to content

Instantly share code, notes, and snippets.

View guiwoda's full-sized avatar

Guido Contreras Woda guiwoda

View GitHub Profile
cd /var/www
mv railsapp railsapp-old
hg clone --updaterev 2.0-stable https://bitbucket.org/redmine/redmine-all railsapp
cp railsapp-old/config/email.yml railsapp/config/configuration.yml
cp railsapp-old/config/database.yml railsapp/config/database.yml
cp -r railsapp-old/files/ railsapp/files/
chown -R root:www-data /var/www/railsapp
cd railsapp
gem install bundler
gem install test-unit
@guiwoda
guiwoda / ExpectationCommandBus.php
Last active August 29, 2015 14:04
Expectation in Commands
<?php
use Laracasts\Commander\CommandBus;
class ExpectationCommandBus implements CommandBus
{
/*
* Constructor injects the resolver...
*/
protected $expectationResolver;
<?php
namespace Acme;
use Symfony\Component\HttpKernel\HTTPKernelInterface;
use Psr\Http\Message\RequestInterface;
class MyMiddleware implements HTTPKernelInterface {
private $kernel;
@guiwoda
guiwoda / foo.php
Last active August 29, 2015 14:11
IoC bindings in Laravel
<?php namespace Acme;
interface IFoo {}
class Foo implements IFoo {}
class Bar {
public function __construct(\Acme\IFoo $foo) {}
}
@guiwoda
guiwoda / example.php
Last active August 29, 2015 14:11
Embeddables with inheritance
<?php
abstract class Framework {
/**
* @type bool
*/
private $installsGlobally;
abstract public function download();
}
@guiwoda
guiwoda / aggregate-root-events.md
Last active August 29, 2015 14:12
Agregate roots and events

Agregate roots and events

Given an aggregate Project, one Team (with many Devs) and one Source, if I $project->releaseEvents(), should the Project aggregate all events from all its related entities?

Example code:

Entities

<?php namespace App\Entities;
@guiwoda
guiwoda / ArticleRepository.php
Created February 12, 2015 17:54
injecting doctrine Repositories
<?php namespace App\Repositories;
// Already mapped to the Container in a ServiceProvider
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
use App\Entities\Article;
class ArticleRepository extends EntityRepository
{
public function __construct(EntityManager $em)
@guiwoda
guiwoda / FooRepository.php
Created February 13, 2015 13:21
Delegate creation responsibility to EM / Repos
<?php
class FooRepository extends EntityRepository implements FooRepositoryInterface
{
public function startFooing($bar, $baz)
{
$em = $this->getEntityManager();
// Let's imagine we could
$foo = $em->create(Foo::class, [$bar, $baz]);
@guiwoda
guiwoda / Money.php
Last active August 29, 2015 14:21
Simple interfaces to convert objects to scalar types and usage examples
<?php
// I left an example in the mailing list with a Money object
class Money implements CastsToString, CastsToFloat {
const DOLLARS = '$';
const POUND = '£';
const YEN = '¥';
private $currency;
private $amount;
@guiwoda
guiwoda / second-level-cache.classes.php
Last active August 29, 2015 14:23
Invalidating association second level cache
<?php namespace App\Entities;
// IGNORE THE CONFIGURATION DETAILS :-)
/**
* @Entity
* @Cache(usage="NONSTRICT_READ_WRITE")
*/
class Post {
/**