Archives for : mindnotes

PHP system, exec, passthru and return code 127

This is a mindnote for myself. If someone else finds it useful, too == profit.

Because of MageFlow development I need to use quite a lot shell commands, for example ping.

Whenever exec, passthru or system returns code 127 check the path of the command. It means that the command cannot be found. It also means that PHP runs the command in such a shell that does not necessarily have PATH set properly and thus the command is not found.

Example

system('ping mygreathost.com', $retval);

$retval is 127.

Specify full path to ping command:

system('/bin/ping mygreathost.com', $retval);

$retval is 0 or 1 depending if mygreathost.com is available or not.

A mindnote regarding Zend 2.0 and interfaces

In Zend FW 2.0 the standard src folder (and namespace) structure is the following:

src\MyNamespace\Model - models
src\MyNamespace\Controller - controllers
src\MyNamespace\Helper - helpers, utilities

However I wanted to follow the same logic for interfaces I failed. The following does not work:
src\MyNamespace\Interface - interfaces

That’s because “Interface” (and interface) is a reserved keyword in PHP.

Mindnote here for next time –  I have to make exception for interfaces and name my namespace (folder) for interfaces in plural:
src\MyNamespace\Interfaces