For cakephp 3.6 and later:
Although above solutions will work but it gives deprecated warning and will not work in cakephp 4.
So It is better to use the following code to get the controller name. It will work in view page and controllers as well.
$this->request->getParam('controller')