开发者

CakePHP - Controller without View & Model

开发者 https://www.devze.com 2023-02-24 16:50 出处:网络
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.

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 = a开发者_如何转开发rray();

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

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

Thanks,

Tee


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

Thanks,
Tee


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


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

public $ uses = null;


$this->autoRender = false;

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

0

精彩评论

暂无评论...
验证码 换一张
取 消