首页  >  文章  >  后端开发  >  PHP MVC自动RBAC访问路由自动生成

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

WBOY
WBOY原创
2016-06-23 13:54:02845浏览

使用关键点:

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

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn