Git Product home page Git Product logo

php-tp-controllers-to-menu's Introduction

Thinkphp 控制器转为菜单数组类库

根据Thinkphp控制器里写的注释来转为菜单数组,供后台功能菜单使用.
只适用于 Thinkphp 3.2 版本

安装

#下载依赖的库并自动生成composer的自动加载类
composer require hwl/thinkphp-controllers-to-menu

使用说明

一般是针对于后台,就使用默认的配置就行,初始化的时候,传入项目文件夹的路径即可

简单示例

//加入命名空间
use Hwl\ThinkphpControllersToMenu\ControllersToMenu;

$controllerFolderPath = __DIR__ . '/Controller';
//初始化并赋值上路径
$ctm  = new ControllersToMenu($controllerFolderPath);

//获取菜单
$menu = $ctm->getMenu();

更改命名空间,即不是默认的Admin项目

默认的命名空间是Admin\Controller

//更改命名空间,注意反斜杠的转义,命名空间的形式
$ctm->setNamespace('Home\\Controller\\');
$menu = $ctm->getMenu();

未测试的功能

这些功能是以前以前的版本有设计该功能,并通过测试的,但在该版本里,是保留,未进行测试的
功能列表:

  • 设置过滤的类
    //该版本已经增加的在注释里进行过滤,但由于继承的父类,所以仍保留这个功能,未进行测试
    /**
     * 设置过滤的类名(菜单栏)
     * @param string $className
     */
    $ctm->setNotClass($className);
  • 设置过滤的类及方法
    //该版本已经增加的在注释里进行过滤,但由于继承的父类及父类的方法,所以仍保留这个功能,未进行测试
    /**
     * 设置过滤的类名及方法
     * @param string $className  类名
     * @param array  $methods    方法名称数组,如何为空数组,则表示过滤整个类 array('methodName','methodName')
     */
    $ctm->setNotClassMethod($className,$methods = array());

其他的请查看代码文件

php-tp-controllers-to-menu's People

Contributors

webberwong avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.