Please tell me how you can receive error messages in the console (there is such a package that allows you to run php-scripts). for example, there is a code:

error_reporting(E_ALL | E_STRICT); ini_set('display_errors', 1); if(!$parent_resources = $modx->getCollection('modResource', array( 'parent' => 3, 'published' => 1 ))){ return; }; $output = ''; foreach ($parent_resources as $parent_resource) { $parent_resource_id = $parent_resource->get('id'); $output .= $parent_resource_id; $child_resources = $modx->getCollection('modResource', array( 'parent' => $parent_resource_id, 'published' => 1 )); }; 

there is an error in it because as a result nothing is displayed on the screen. but I would like to receive at least some messages

As you can see, I included error_reporting and ini_set at the beginning of the script. I also registered in .htaccess:

 php_flag display_errors On php_value error_reporting "E_ALL & ~E_NOTICE" 

But it does not help.

ps: Please do not tell me how to fix the above script. The question is not how to fix it, the question is how to get error messages in principle.

    3 answers 3

    There are two types of errors in the modic:

    1. Php errors - these can be viewed in the Apache logs.
    2. Modix errors (derived through $ modx-> log), which can be viewed in the error log.

    Decide for a start what type of mistakes you want to watch, then go watch the logs.

      The modx error log is in modx_core/cache/logs/error.log

      It can be viewed by downloading via ftp, or via ssh.

      You can also access the error log via the modx admin panel by selecting in the menu: Management -> Reports -> Error Log

        To write debug information to the MODx error log from a snippet, use the following code.

         $err = print_r(data, 1); $modx->log(modX::LOG_LEVEL_ERROR,'debug message: '.$err); 

        The error log is available from the menu Manage -> Reports -> Error Log

        • print_r(data) outputs information to the stream, but print_r(data,1) return the string - Vasis
        • Vasis, That's right! - Sequent