# Can i call the controller method into our shell program?

**URL:** https://discourse.cakephp.org/t/can-i-call-the-controller-method-into-our-shell-program/9301
**Category:** Uncategorized
**Created:** [April 27, 2021, 9:19am UTC](https://discourse.cakephp.org/t/can-i-call-the-controller-method-into-our-shell-program/9301 "2021-04-27T09:19:27Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![spadeX](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@spadeX](https://discourse.cakephp.org/u/spadeX)
#### Post date: [April 27, 2021, 9:19am UTC](https://discourse.cakephp.org/t/can-i-call-the-controller-method-into-our-shell-program/9301/1 "2021-04-27T09:19:28Z")

</div>

can i call the controller method into our shell program ?

---

<div class="post-metadata">

### Author: ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)
#### Post date: [April 27, 2021, 8:35pm UTC](https://discourse.cakephp.org/t/can-i-call-the-controller-method-into-our-shell-program/9301/2 "2021-04-27T20:35:01Z")

</div>

You shouldn’t, no. Whatever bit of code you need to execute in both the controller and the shell should be moved into some other place, and then both the controller and the shell call it there. Where to move it to depends on what kind of code it is. If it’s very model-related, for example, then moving it into the relevant model is best. If nowhere seems obvious, then create a utility class somewhere (e.g. in an App\Utility namespace) for it.

---

<div class="post-metadata">

### Author: ![spadeX](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@spadeX](https://discourse.cakephp.org/u/spadeX)
#### Post date: [April 29, 2021, 4:59am UTC](https://discourse.cakephp.org/t/can-i-call-the-controller-method-into-our-shell-program/9301/3 "2021-04-29T04:59:30Z")

</div>

Thanks for suggestions. I got the right direction.
