It's good practice to give a return in a simple PHP file example:
<?php
$config['teste'] = 123;
return $config;
I will explain better this file di / dependencias.php:
<?php
$container['daoExemplo'] = function ($c)
{
return new ExemploDAO();
};
return $container;
I need to add all the anonymous functions contained in this file in a method, in case it will go through the entire directory di / example:
public function requireAllDependencies($directory)
{
try {
//setando o diretorio e o tipo de arquivo a ser carregado
$dir = "{$directory}/*.php";
//Percorrendo o diretorio e pegado o caminho dos aquivo
foreach (glob($dir) as $filename)
{
//Adicionando as dependencias
$dependencies = require $filename;
$this->add($dependencies);
}
} catch(Exception $e) {
echo "Erro ao tentar adicionar o arquivo: " . $e->getMessage();
}
}
In this example would it make sense?