Get all Functions Names of All CONTROLLERS |
Hello I want to create a new controller in controllers folder
and want to get all controllers names in controllers name and then all function names in each controller but i need to write code in only one controller so far i succeed in getting all controller names but i don't know how to get each function name in each controller plz help me
get_class_methods() should do the trick.
Another possible way is using http://www.php.net/manual/en/function.token-get-all.php
but it requires writing code for detection a sequence of tokens, for example: T_PUBLIC T_WHITESPACE T_FUNCTION T_WHITESPACE T_STRING Edit: Trying how it works: Code: $source = <<<EOT I have never used the tokenizer, it requires a little bit practicing, but it seems to me a good choice for this task. (02-03-2016, 11:14 AM)ivantcholakov Wrote: @kilishan That's true, it will parse them all, but I'm pretty sure that it, being a native method written in C, is likely to have better performance than a regular expression. While I think either way could work, I think the performance difference would be negligible between the two. And, since I don't know what the purpose is, I would personally go with the easier solution. Then, if performance was found to be an issue down the road, I would simply cache the results.
There is a Zend package capable of doing this, but it requires time for learning, indeed. It uses a tokenizer. Namespace for ZF2: Zend\Code\Scanner
Here is a test that gives an idea on the subject: https://github.com/zendframework/zend-co...t.php#L130
Maybe:
PHP Code: $this->load->helper('file'); |
Welcome Guest, Not a member yet? Register Sign In |