Home  >  Article  >  Backend Development  >  PHP MVC自动RBAC访问路由自动生成

PHP MVC自动RBAC访问路由自动生成

WBOY
WBOYOriginal
2016-06-23 13:54:02893browse

使用关键点:

ReflectionClass


class Rbac extends MY_Controller{    public function index()    {        $arr = glob(  __DIR__ .DIRECTORY_SEPARATOR. '*.php');//        $arr = glob(dirname(__DIR__) . DIRECTORY_SEPARATOR . '*');        $MVC = array();        foreach ($arr as $path) {            $basename = basename($path, '.php');            //仅支持合法的命名            if (preg_match('/^\w+$/', $basename) && $path != __FILE__) {                require $path;                $className = ucfirst($basename);                $ref = new ReflectionClass($className);                foreach ($ref->getMethods() as $key => $methods) {                    var_dump( get_class_methods($methods));                    if($methods->isPublic()){                        $MVC[$methods->class][] = array(                            $methods->getName(),                            $methods->getFileName(),                        );                            $methods->name;                    }                }            }        }        var_dump($MVC);    }}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php中倒计时的问题Next article:phpwind 图片上传问题!