Structure for PHP project and use of eval() function


I need to develop an application that fits several projects with common features, however each one has several specific rules.

What I need is a structure that allows me to easily change these rules, in this case I chose to save the rules in the database and use the eval() function to execute the code in the application, however, I don't think this would be the best option to get the result I need (not even the safest, even if the rules are encrypted).

Structure I am using now is:

    controller [controllers]
    model [models] [aqui são aplicados as regras do banco de dados]
    entity [entidades do banco de dados]
    repository [model <=> entity]
    helper [helpers]
    view [views]
    theme [themes]
    [configurações da aplicação]
    logs [app logs]
    cache [view cache]
    [módulos angular, assets, index.php e .htaccess]
    [libraries, app-core]

The rules would be applied something like this:

// Random key (config)

// antes

foreach ( regras as regra )
    parse(decode(regra, PRIVATE_KEY));

// continua execução

Any ideas on how I could improve this?


Why don't you use classes? For example:

interface Regras {
    public function execute();

class RegrasApp implements Regras {
    public function execute() {
        // suas regras aqui

$regras = new RegrasApp();
Scroll to Top