We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

HMVC

Всем добрый день. Разбираю приложение HMVC В экшене helloAction есть такой код

return new Response('hello there');

Если заменить его на

return 'hello there';

Ничего не меняется, и так и так работает. Вопрос, зачем нужен new Response ?



2.1k
Accepted
answer

first of all english please.

It works because by default the FactoryDefault() already created a response and view.

It will try to load any view if available, and then respond to the request using the response handler.

But when you return a new response, it will not look for any view but just return the text hello there.

pretty sure i am right.

first of all english please.

It works because by default the FactoryDefault() already created a response and view.

It will try to load any view if available, and then respond to the request using the response handler.

But when you return a new response, it will not look for any view but just return the text hello there.

pretty sure i am right.

I'm sorry, thank you