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:
| class MyClass { | |
| /** | |
| * @Inject | |
| * @var MyService | |
| */ | |
| private $service; | |
| } |
| # Inspired from http://blog.hio.fr/2011/09/17/doctrine2-yaml-mapping-example.html | |
| MyEntity: | |
| type: entity | |
| repositoryClass: MyRepositoryClass | |
| table: my_entity | |
| namedQueries: | |
| all: "SELECT u FROM __CLASS__ u" | |
| # Class-Table-Inheritance |
| ; PHP developer shortcuts for BÉPO keyboard layouts | |
| ; Need AutoHotkey_L to support unicode encoding (http://www.autohotkey.com/download/) | |
| ; "->" for PHP (when typing <Alt>+8) | |
| !-:: | |
| Send -> | |
| return | |
| <?php | |
| namespace Doctrine\Tests\Models\DDC1734; | |
| /** | |
| * @Entity | |
| */ | |
| class DDC1734Article | |
| { |
| <?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; | |
| /** |
| sudo apt-get install subversion git mercurial python perl ruby |
Reflections on PHP-DI configuration.
Currently, the configuration is in PHP or annotations, PHP config has the following advantages:
Disadvantages of PHP:
| <?php | |
| // See also http://en.mnapoli.fr/the-optional-singleton-pattern/ | |
| class MyService | |
| { | |
| private static $singletonInstance = null; | |
| /** | |
| * Keep the constructor public | |
| */ |
| <?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); |