I am making a controller that will be responsible for a bunch of actions and I don’t want to have to create a view file for each one, sometimes i just want to output strings.
I could just do echo 'Hello World'; die(); into the action.
but is there a more correct way to do this?
Yes, in the controller you can disable view rendering like this:
And you add whatever you like to the output like this:
There are other things you can do with the Response object too: