How to use Http\Server to replace Dispatcher

Previously I was using Dispatcher to dispatch request
$request = new Request($path);
$dispatcher = DispatcherFactory::create();
$response = new Response();
$dispatcher->dispatch(
$request,
$response
);

Now I am upgrading my cakephp application to 3.8 and want to replace this dispatcher class to ‘Http/Server’ implementation as suggested in deprecation warning.

Kindly help.

You need to convert your app to the middleware stack as described here:

https://book.cakephp.org/3/en/development/application.html#adding-http-stack

I’d also recommend looking at the app template for 3.8 and convert your app to this base structure.

Actually, I am using dispatcher to forward the request from Shell to controller action. Is there any way to do this in cakephp 3.8 without dispatcher.

you shouldn’t “forward” something from the shell to a controller action.

You should instead extract that controller action into a generic service class and call it in both your controller and your command.

See https://www.youtube.com/watch?v=z3E_UdH1XeE