XF 2.1 Is it possible to extend App.php

AndyB

Well-known member
I would like to create an add-on which would allow switching to development mode from within the Admin control panel.

Is it possible to extend the App.php file?

Currently I have created an add-on called Development mode and extended App.php the way I have with many other add-ons, that is to use the XFCP system, however it doesn't work.

PHP:
<?php

namespace Andy\DevelopmentMode\XF;

class App extends XFCP_App
{
	public function checkDebugMode()
	{
		
	}
}

Thank you for your help.
 
No, the app classes are instantiated directly. There are a handful of code events for hooking into them though. In your case, I'd look into hooking app_setup (as that's where the method you wanted to extend gets called anyways). It looks like enabling debug mode is about as simple as:
PHP:
\XF::$debugMode = true;
@ini_set('display_errors', true);

This assumes nothing relevant to debug mode happens in between checkDebugMode() and the event firing, which seems to be the case at a glance but might be worth double checking.
 
Top Bottom