Tuesday 12 August 2014

Zend Framework 2 Depencency Injection

I found myself having to reteach myself the Zend Framework 2 DI system this week.

This is a great quick start to get the development environment running.

http://ocramius.github.io/blog/zend-framework-2-controllers-and-dependency-injection-with-zend-di/

And for production it's better to use factories.

http://www.zfdaily.com/2012/07/getting-dependencies-into-zf2-controllers/

Monday 28 July 2014

Problems with pdepend and phpmd dependencies in composer

I added phpmd to my composer.json for project but got this error when I tried to run phpmd.

vendor/bin/phpmd . codesize,design,naming,unusedcode --reportfile build/reports/messdetector.html --exclude vendor,build PHP Warning: require_once(PHP/Depend/Autoload.php): failed to open stream: No such file or directory in /mnt/hgfs/workspace/programmes-service/vendor/phpmd/phpmd/src/main/php/PHP/PMD/ParserFactory.php on line 48

This seems to be an issue with pdepend 2.0.0, adding the line below to pdepend 1.1.1 to you composer.json should fix the problem.

pdepend/pdepend" : "1.1.1"

Tuesday 4 February 2014

PHP CLI config on Mac

Quick post following a bit of frustration this morning.  I had an issue with phpmd and phpcs not being able to find my pear libs.


Warning: include_once(PHP/CodeSniffer/CLI.php): failed to open stream: No such file or directory in /usr/bin/phpcs on line 31 Warning: include_once(): Failed opening 'PHP/CodeSniffer/CLI.php' for inclusion (include_path='.:') in /usr/bin/phpcs on line 31 Fatal error: Class 'PHP_CodeSniffer_CLI' not found in /usr/bin/phpcs on line 34 Warning: require_once(PHP/PMD/TextUI/Command.php): failed to open stream: No such file or directory in /usr/bin/phpmd on line 45 Fatal error: require_once(): Failed opening required 'PHP/PMD/TextUI/Command.php' (include_path='.:') in /usr/bin/phpmd on line 45

This was because there is no php cli config file by default (in mavericks at least). Linking the existing php.ini.default to php.ini resolves this issue.

sudo ln -s /etc/php.ini.default /etc/php.ini

Tuesday 7 January 2014

Installing composer from a local or private location

This looks useful for loading personal or work libraries that are not hosted on github via composer.

http://marekkalnik.tumblr.com/post/22929686367/composer-installing-package-from-local-git-repository