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

来源:互联网 发布:佛山公交线路查询软件 编辑:程序博客网 时间:2024/06/05 11:13

使用关键点:

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

0 0
原创粉丝点击