I just wanted to check I had the right approach here. I am trying to make all my existing controllers extend my own super controller. From the guide I see that I need something like this. But where should I be putting this file?
class MyController extends Controller
Where should I put this file though?
I usualy create a folder named components and put it in there. But you can place it anywhere you like.
Don’t forget to adjust the namespace in your file too.
// This is what you have right now.
// It means the path of MyController is app/controllers/MyController.php
// And this means it's stored in app/components/MyController.php
Also since Yii2 uses namespace, you don’t need to use a different name like ‘MyController’. You can name it ‘Controller’ and it won’t cause a name conflict because it is not in the same namespace.
Which directory would you suggest? In the Document where the config, controller,model folders are?
Well say your project is called myApp, your directory structure would look a bit like this:
-- components // this (remember, you can name it whatever you like, that's just what I chose)
---- Controller.php // and this (again, you can name it whatever you like).