teepusink
teepusink

Reputation: 28892

CakePHP - Controller without View & Model

How do I create a controller with no view and model?
Making a services_controller to spit out json.

This is what I have now.

var $uses = array();

function test() {
    $this->autoRender = false;
    echo "test";
}

However, that doesn't print out the "test" message.

Thanks,
Tee

Upvotes: 13

Views: 11884

Answers (4)

Sohan Arafat
Sohan Arafat

Reputation: 93

$this->autoRender = false;

This one works like a die() function. Put it at the end of the function.

Upvotes: 0

Devendra Soni
Devendra Soni

Reputation: 391

Just write $this->autoRender = false; at the end of the function. It will surely work.

Upvotes: 3

I know that using the statement below your controller is without reference to any model:

public $ uses = null;

Upvotes: 0

teepusink
teepusink

Reputation: 28892

The above code actually works. The issue was somewhere else related to the Auth component.

Thanks,
Tee

Upvotes: 4

Related Questions