Jump to content

Recommended Posts

Posted

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?

Posted

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();

 

  • Like 1
Posted

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?

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...