DI containers are sorted alphabetically.
This file contains hidden or 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 | |
class UserController | |
{ | |
/** | |
* @Inject | |
* @var RouterInterface | |
*/ | |
private $router; | |
/** |
This file contains hidden or 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 A\Long\Namespace\User; | |
use Some\Namespace\ProductService; | |
// Doctrine: get entity | |
$user = $entityManager->find('A\Long\Namespace\User', 1234); | |
$user = $entityManager->find(User::class, 1234); | |
// Doctrine repositories |
This file contains hidden or 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
# Given | |
Given I am on [the] homepage | |
Given I am on "url" | |
# When | |
When I go to [the] homepage | |
When I go to "url" | |
When I reload the page |
This file contains hidden or 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 | |
/** | |
* In this example, a collection is a map of values indexed by a key (numeric or string) | |
*/ | |
interface Collection extends Countable, IteratorAggregate, ArrayAccess | |
{ | |
function add($value); | |
function set($key, $value); |
This file contains hidden or 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 | |
// See also http://en.mnapoli.fr/the-optional-singleton-pattern/ | |
class MyService | |
{ | |
private static $singletonInstance = null; | |
/** | |
* Keep the constructor public | |
*/ |
Reflections on PHP-DI configuration.
Currently, the configuration is in PHP or annotations, PHP config has the following advantages:
- PHP developpers know PHP
- IDE autocompletion/error detection
- Bean definition using closures
Disadvantages of PHP:
This file contains hidden or 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
sudo apt-get install subversion git mercurial python perl ruby |
This file contains hidden or 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 | |
/** | |
* @author Matthieu Napoli | |
* @link http://en.mnapoli.fr/doctrine-schema-validation-in-a-phpunit-test/ | |
* @license WTFPL - Do What The Fuck You Want To Public License (http://sam.zoy.org/wtfpl/) | |
*/ | |
use Doctrine\ORM\Tools\SchemaValidator; | |
/** |