When debugging complex applications you sometimes need to find out where a method of an object instance has been defined. With several levels of inheritance this can sometimes become quite time consuming. This is where PHP’s Reflektion API comes in handy. This API allows you to reverse-engineer classes, functions & methods.
If see in your code that an object instance $foo calls a method bar and you want to know in which file bar is defined.
You could use get_class($foo) to find the name of the class, then find the class definition in your code and then go backwards through the classes the class inherited from, to find the method definition. Using the Reflektion API allows you to find the file in one step.
$rc = new ReflectionClass($foo);
$method = $rc->getMethod('bar');
Have a look at ReflectionMethod for more details.
Took over a project that had previously been outsourced to an Indian company.
// Thanks for the review. I would like to request you to arrenge Rs.2000 more/pm. It would be great if you can do that.
$_helper = $this->helper('catalog/output');
PWX has been restructured to support multiple languages. José Luis Cruz contributed a Spanish translation. Currently English, German and Spanish are supported. I’m happy to support pull requests for other languages.
Travis CI offers an excellent and free! continuous integration service. It runs your unit tests after you pushed your code to GitHub and deploys your changes to your staging/production servers if your tests pass.
One of the issues I run into while setting up my application with Travis was that my tests require email to work. By default tests sending emails will fail because the underlying mail system is disabled. In my case testing a ZF2 application, the error message was along those lines:
Configuration read from /home/travis/build/[...]/phpunit.xml
..............................sh: 1: -t: not found
Time: 5 seconds, Memory: 73.00Mb
There was 1 error:
Zend\Mail\Exception\RuntimeException: Unable to send mail: Unknown error
To work around this you need to set up a mock mail service. This requires you to set up your .travis.yml according to this example:
- sudo apt-get update -qq
- sudo apt-get install -y -qq postfix
- sudo service postfix stop
- smtp-sink -d "%d.%H.%M.%S" localhost:2500 1000 &
- echo -e '#!/usr/bin/env bash\nexit 0' | sudo tee /usr/sbin/sendmail
- echo 'sendmail_path = "/usr/sbin/sendmail -t -i "' | sudo tee "/home/travis/.phpenv/versions/`php -i | grep "PHP Version" | head -n 1 | grep -o -P '\d+\.\d+\.\d+.*'`/etc/conf.d/sendmail.ini"
This solution is based on the PHPMailer Travis configuration. Thanks!