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

How create sub request in phalcon

How can you get this functionality in Phalcon 3?

https://silex.sensiolabs.org/doc/master/cookbook/sub_requests.html

$response = $app->handle($subRequest, HttpKernelInterface::SUB_REQUEST, false);
edited Oct '16

$response = $app->handle("/someUrl")

Or just extends phalcon Request, add setters to it, then create new request, set whatever you want, add it do di and do $app->handle()



79.0k
Accepted
answer

@Jurigag: I guess it's not about routing nor handling primary request, it's about "sub request", a term which does not exist in a HTTP world, but closest thing to this Symfony approach would be Disaptcher in Phalcon.

Since Silex is based on the HttpKernelInterface, it allows you to simulate requests against your application. This means that you can embed a page within another, it also allows you to forward a request which is essentially an internal redirect that does not change the URL.

Basically, they inject entire HTTP request into another 'route', which is then handled by some other controller/script. In Phalcon, you don't even need to do it as there is a shared Request service.

edited Oct '16

I'm using micro and you can not use the dispatcher.

I'm looking for a way to make widgets, any ideas?

It does not seem a good idea to sub-request, I will follow the advice of @stamster and I will create another discussion on the topic of widgets and blocks.