Maison  >  Article  >  développement back-end  >  PHP MVC自动RBAC访问路由自动生成

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

WBOY
WBOYoriginal
2016-06-23 13:54:02845parcourir

使用关键点:

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

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Article précédent:php中倒计时的问题Article suivant:phpwind 图片上传问题!