# How to use Http\\Server to replace Dispatcher

**URL:** <https://discourse.cakephp.org/t/how-to-use-http-server-to-replace-dispatcher/12222>\
**Category:** Need Help\
**Tags:** help\
**Created:** [September 3, 2024, 7:17am UTC](https://discourse.cakephp.org/t/how-to-use-http-server-to-replace-dispatcher/12222 "2024-09-03T07:17:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kuldeep1984](https://avatars.discourse-cdn.com/v4/letter/k/ecc23a/32.png) [@kuldeep1984](https://discourse.cakephp.org/u/kuldeep1984)\
**Post date:** [September 3, 2024, 7:17am UTC](https://discourse.cakephp.org/t/how-to-use-http-server-to-replace-dispatcher/12222/1 "2024-09-03T07:17:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [September 3, 2024, 9:12am UTC](https://discourse.cakephp.org/t/how-to-use-http-server-to-replace-dispatcher/12222/2 "2024-09-03T09:12:32Z")

</div>

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](https://book.cakephp.org/3/en/development/application.html#adding-http-stack)

I’d also recommend looking at the [app template for 3.8](https://github.com/cakephp/app/tree/3.8.0) and convert your app to this base structure.

---

<div class="post-metadata">

**Author:** ![kuldeep1984](https://avatars.discourse-cdn.com/v4/letter/k/ecc23a/32.png) [@kuldeep1984](https://discourse.cakephp.org/u/kuldeep1984)\
**Post date:** [September 3, 2024, 10:42am UTC](https://discourse.cakephp.org/t/how-to-use-http-server-to-replace-dispatcher/12222/3 "2024-09-03T10:42:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [September 3, 2024, 10:44am UTC](https://discourse.cakephp.org/t/how-to-use-http-server-to-replace-dispatcher/12222/4 "2024-09-03T10:44:46Z")

</div>

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](https://www.youtube.com/watch?v=z3E_UdH1XeE)
