Archive for the ‘PHP’ Category

PHP 5.6 (5.6.13) vs PHP 7.0 (7.0.0RC2) vs opcode cache performance benchmark with common applications

Sunday, September 6th, 2015

This benchmark is a quick test to confirm (or not!) what benchmarks on the internet report lately: PHP 7.0 performs better than its predecessors.

(more…)

cPanel EasyApache YUM error: couldn’t create autoTLSkey mapping

Saturday, August 15th, 2015

If you ever encounter this error while running EasyApache (v3) on cPanel server:

This is the solution:

I have a hunch that was is IPv6 related, but can not confirm it ATM. Funny thing though: If I ran the exact same command in the shell by copy-pasting it and prepending it with “yum “, it worked flawlessly.

Zend Framework 2 – modules with sub namespaces

Tuesday, November 25th, 2014

The problem – readability

Let us imagine you have a neat organization called “My Organization”, for example. This organization produces software modules, and at one point in time you have decided to adopt Zend Framework 2 module structure. According to ZF2 module naming guidelines you should name your modules as “MyOrgMyModule”, presuming “My Organisation” name is shortened into “MyOrg”. Consequentially namespace is called like this: “MyOrgMyModule\MyClass”.

To enable this module in your ZF2 application, you have to enable it in your application config file (named ./config/application.config.php by ZF2 convention):

Soon someone is bound to notice that namespace operator (“\”) would provide better readability of said modules, and as PHP supports unlimited sub namespaces (unlimited for purpose of this discussion), it would be far better to use that than to just cram UCfirst words one after another. Like this:

The snag

The snag is – your module directories (./module, ./vendor) must follow the exact naming pattern as module names/namespaces. Therefore:
– module name MyOrg\Subset1\Module2 (with the same namespace)
– becomes directory ./module/MyOrg/Subset1/Module2.

But, if you publish your modules, for example on Github, there is no way to clone into subdirectory by default. Also, you usually name Github projects more expressively, for example: php-zf2-module-MyModule1.

The clone command:

will clone into ./php-zf2-module-MyModule1 directory.

Workaround #1 – adjusted directory structure

The obvious answer is: clone into appropriate subdirectory, like this:

This is a fine approach. The only downside is that visual similarity between directory name and Github project name is lost (it is still available in ./vendor/MyOrg/MyModule1/.git/config file though).

Workaround #2 – explicit module path configuration

Then, configure per-ZF2-module paths in you ./config/application.config.php:

Workaround #2 – alternative, more verbose directory structure

For even greater readability, you should clone your modules into vendor-named subdirectories, like this:

Then configure per-ZF2-module paths in you ./config/application.config.php: