Welcome Guest, Not a member yet? Register   Sign In
How to check if a controller exists?
#1

[eluser]macigniter[/eluser]
I need a function to check whether a controller exists. Similar to the PHP function "file_exists()"...

Is something like that already built in? I didn't find it Sad
#2

[eluser]GSV Sleeper Service[/eluser]
well, a controller is a file, so use file_exists().
take a look at system/libraries/Router.php, line 194 ish. CI uses file_exists() to check to see if the controller exists.
the alternative is to just try to access the controller in your browser, if you get a 404, it doesn't exist!
#3

[eluser]Michael Wales[/eluser]
Technically, a Controller is a class and you must instantiate that object before it ever exists. Therefore, you could have 800 files in your controllers directory, but the only time a controller exists is when it is being called.




Theme © iAndrew 2016 - Forum software by © MyBB