8
It is good practice to give a Return in a simple PHP file example:
<?php
$config['teste'] = 123;
return $config;
I’ll explain better I have this file di/dependencias.php:
<?php
$container['daoExemplo'] = function ($c)
{
return new ExemploDAO();
};
return $container;
I need to add all the Anonimas functions contained in this file in a method, in case it will go through the whole di/ example directory:
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 that example it would make sense ?
It makes sense that?
– rray
What is the objective?
– Paulo Ramos
@rray Incredibly, in certain cases does.
– bfavaretto
I’ve added a few more explanations, I hope it makes more sense.
– Lucas Lima