简体   繁体   English

数据库中的Zend Framework 2模块配置

[英]Zend Framework 2 Module config from database

i am currently working on a project with zend 2 framework and i am trying to find out if its possible to controll whether a module is activ or not by the database. 我目前正在使用zend 2框架进行项目,并且试图找出是否有可能控制数据库是否激活了某个模块。

I am trying to create an admin panel for my project and there i want to active and deactivate modules. 我正在尝试为我的项目创建一个管理面板,我想在其中激活和停用模块。

One thought was to load the config from the database in the "index.php" file before this line of code : 一种想法是在以下代码行之前从数据库的“ index.php”文件中加载配置:

// Run the application!
Zend\Mvc\Application::init(require 'config/basic.config.php')->run();

So instead of using the config from basic.config.php i will load the data from the database and create an array just like the one in the basic.config.php file. 因此,我将不使用basic.config.php中的配置,而是从数据库中加载数据并创建一个数组,就像basic.config.php文件中的数组一样。

Would this be the right way to achieve this ? 这是实现此目标的正确方法吗?

Is it also possible to load a module config from database ? 是否还可以从数据库加载模块配置? So i can change the route for a module from the admin panel. 因此,我可以从管理面板更改模块的路由。

Cheers ! 干杯!

My suggestion is to write information from admin panel in configuration files by Writer . 我的建议是通过Writer从管理面板中将信息写入配置文件中。 If you use PhpArray then read configuration without parsing and reading from files is faster than the database. 如果您使用PhpArray,则无需解析和读取文件即可读取配置比数据库快。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM