Errors

Errors are the oldest form of error handling in PHP dating all the way back to PHP 3. Trigger_error is still useful in certain very limited circumstances owing to the fact that, unlike exceptions, errors cannot be caught or if they don't stop the system then code continues on the line following trigger_error. Drupal primarily makes use of Exceptions and assertions, using errors only when necessary to cause an immediate halt of the system.

Exceptions

Exceptions are the preferred method of fault handling in Drupal. They should be used in all cases but two.

Assertions

A runtime assertion is a statement that is expected to always be true at the point in the code it appears at. They are tested using PHP's internal assert() statement. If an assertion is ever FALSE it indicates an error in the code or in module or theme configuration files. User-provided configuration files should be verified with standard control structures at all times, not just checked in development environments with assert() statements on.

Faults: Assertions, Errors, and Exceptions

(API still in development)

Sooner or later problems occur in all computer programs. There are three problem groups in PHP

Locating template files

If you want to know which template is generating a particular markup element, you can use Twig's debug option.
Besides the name of the template files it also reveals its location.

You enable Twig debugging in sites/default/services.yml. Set the variable debug in the section twig.config to true.

After you have set debug to true, clear the caches.

How to use Xdebug and PhpStorm with VDD

How to use Xdebug and PhpStorm with VDD

VDD supports out of the box Xdebug working configuration. You can simply start you virtual environment, open your project with PhpStorm and start debugging.

Preparations

To make your debugging more comfortable you should install Xdebug helper extension in your browser. I'll use Google Chrome in this example.

Pages

Subscribe with RSS Subscribe to RSS - debugging