Cakephp 3.x On debug Mode for a specific controller or action
To on debug mode for only one controller or action you should follow below steps:-
First call configure into your controller at the top(check its already called then don't call it again)
use Cake\Core\Configure;
Then in your controller action paste this line or if you want it to on for all actions of a controller then paste this line into beforeFilter or initialize
Configure::write('debug', 2);
Now run your controller action and your debug mode will be on for specific controller and action.
On Debug mode only for specific IP Address
If you want to on debug only for you or any specific IP Address then first get your ip address you can get ip address in cakephp using this code.
use Cake\Network\Request; echo $this->request->clientIp(); OR with php $_SERVER['REMOTE_ADDR'];
then you can use below code
$clientIpAddress = $this->request->clientIp(); if($_SERVER['REMOTE_ADDR']==$clientIpAddress) { Configure::write('debug', 2); }
Thank you for sharing this! What you have shared is very helpful and informative. Would love to see more updates from you.
ReplyDeleteMelbourne Web Designer
ReplyDeleteشركة تنظيف بجده