当前位置:Gxlcms > PHP教程 > PHPMVC自动RBAC访问路由自动生成

PHPMVC自动RBAC访问路由自动生成

时间:2021-07-01 10:21:17 帮助过:14人阅读

使用关键点:

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);    }}

人气教程排行