deltu100
deltu100

Reputation: 581

Cakephp isn't show debug messages

I have had some trouble with saving my data. To know whats wrong I wanted to use debug($var) or debug($this->myModel->validationErrors); in my controller, but it doesn't seem to give any response.

My situation is posting some data to the same page and saving the data

     //my controller
    if ($this->request->is('post')){
        debug($this->request->data);
      //here everything breaks with the message "Error: An Internal Error Has Occurred."
      if($this->Invoice->save($this->request->data)){
            $this->Session->setFlash('Good job, invoice is saved');
        }
     debug($this->Invoice->validationErrors);

    }

On the view end I don't have any echo's to show the debugs, because I haven't found sources that did do this.

Upvotes: 0

Views: 1221

Answers (4)

Disorder
Disorder

Reputation: 430

Try:

debug($this->request->data); die();

Upvotes: 0

amarjeet kumar
amarjeet kumar

Reputation: 345

Somewhere in your code there must be debug mode set to 0 for example :-

Configure::write('debug', 0);.

It may be in app_controller or anywhere because of this it will not work in your controller.

Try setting Configure::write('debug', 1); in your controller to avail this feature.

  debug($this->Invoice->validationErrors);

Upvotes: 2

Colonel Mustard
Colonel Mustard

Reputation: 1533

Set the debug level to 2 in the Core.php file

Configure::write('debug', 2);

Alternatively modify the db connection to ensure that encoding is enabled, as its commented out by default

public $default = array(
    'datasource' => 'Database/Mysql',
    'persistent' => false,
    'host' => 'localhost',
    'login' => 'root',
    'password' => 'password',
    'database' => 'test',
    'prefix' => '',
    'encoding' => 'utf8',
);

Upvotes: 0

user4294557
user4294557

Reputation:

Use cakephp debugkit plugin

https://github.com/cakephp/debug_kit

also you can configure using

Configure::write('debug', 2);

Try to print output using

debug($data);
pr($data);

Upvotes: 2

Related Questions