Peter Oehman Posted April 6, 2022 Share Posted April 6, 2022 I'm trying to use a class in a file outside of ProcessWire, the classes name is captcha. When trying to access it this is the error message: Uncaught Error: Class 'ProcessWire\CAPTCHA' not found I'm guessing this is ProcessWire looking for any classes in the system and not finding any, so how can I access this class? Link to comment Share on other sites More sharing options...
Peter Oehman Posted April 6, 2022 Author Share Posted April 6, 2022 I should note that this error doesn't occur while requiring the file, but it occurs when I try to make a 'new Captcha' Link to comment Share on other sites More sharing options...
bernhard Posted April 7, 2022 Share Posted April 7, 2022 The error message shows that you are trying to create a new Instance of CAPTCHA but in the ProcessWire namespace. This is because you have something like this at the top of your file: <?php namespace ProcessWire; Simply adding a \ should fix this error: $cap = new \CAPTCHA(); 1 Link to comment Share on other sites More sharing options...
ttbb Posted April 13, 2022 Share Posted April 13, 2022 i've a problem mutally in the same area: coming from drupal where krumo (http://krumo.kaloyan.info/) is part of the widely used development module and an easy way to insert krumo(object/variable/array) at any place to have a handy you have a collapsed view of the input as a great replacement of print_r. i'm frequently using it also in php projects (without namespaces). i include it in processwire like this: define('dir', dirname(__FILE__)); include_once(dir.'/includes/krumo/class.krumo.php'); krumo::$skin = 'orange'; // just a theme of krumo krumo works fine as expected as long as i use e.g. »normal« php arrays. when i hand over a WireArray, e.g. a page array it stops working with fatal errors, obviously due to krumo being called as class inside of another namespace. i fiddled around with the $wireArray->getArray() method, but no avail. how can i globally display the processwire objects the same way as standard php objects? ... or does anyone an alternative method of displaying any kind of data (objects/arrays/variables) for debugging with a page? Link to comment Share on other sites More sharing options...
bernhard Posted April 13, 2022 Share Posted April 13, 2022 Maybe not a solution to your problems, but have you already tried https://processwire.com/modules/tracy-debugger/ ? I think it does what you are looking for and so much more ? 1 Link to comment Share on other sites More sharing options...
ttbb Posted April 13, 2022 Share Posted April 13, 2022 thanks a lot for pointing me to tracy debugger. the d() method is what i'm looking for ? Link to comment Share on other sites More sharing options...
bernhard Posted April 13, 2022 Share Posted April 13, 2022 Yes, if you want to dump directly (like echo), then d() is what you are looking for. But you can also use bd() to dump everything in the debug bar (bottom right). That's especially handy in ajax calls and such. Link to comment Share on other sites More sharing options...
ttbb Posted April 13, 2022 Share Posted April 13, 2022 bd() is nice as well. thanks for this additional hint! ? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now