Unable to use Zend_Debug :: dump in ZF2 .. like me?

I am using a skeleton application for ZF2.0.0Beta3.

So, usually I just used Zend_Debug :: dump ($ someVar); however, in ZF2, it does not include zend classes.

The error is: Fatal Error: Class 'Zend_Debug' not found.. 

This is probably really the main question, but what is the best way to include this class? Should I put require_once('path/to/Debug.php'); ?

+4
source share
4 answers

It still exists in ZF2, but since ZF2 started using PHP namespaces , now you need to call it using the Zend namespace:

\Zend\Debug\Debug::dump($var);

or add a use statement at the beginning of the file and call it like this:

 use Zend\Debug\Debug; Debug::dump($var); 
+13
source

In my case, this was the correct namespace path:

 \Zend\Debug\Debug::dump($form); 
+5
source

Alternatively, you can do it as follows:

 use Zend\Debug\Debug; // ... Debug::dump($someVar); 

It seems like a lot of work just to reset the variable. I am pretty sure that in most cases I just use \Zend\Debug\Debug::dump() more often.

+2
source

You can use it like this:

 \Zend\Debug::dump('asd') 
0
source

Source: https://habr.com/ru/post/1400322/


All Articles