1. Go to this page and download the library: Download dev-macb/ambivar library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dev-macb / ambivar example snippets
use MacB\Ambivar;
Ambivar::inicializar(__DIR__); // Opcional
Ambivar::dotenv(); // Carrega o arquivo .env padrão
Ambivar::carregar(".env.dev"); // Carrega um arquivo específico
// Retorna true se o arquivo foi carregado com sucesso
$resultado = Ambivar::dotenv();
// Carrega um arquivo .env específico
$resultado = Ambivar::carregar('/caminho/completo/.env.production');
// Retorna o número de arquivos carregados com sucesso
$contador = Ambivar::carregarDiretorio(__DIR__ . '/environments');
if (Ambivar::existe('SECRET_KEY')) {
// A variável existe
}
// Obtém APP_DEBUG ou retorna false se não estiver definido
$valor = Ambivar::obter('APP_DEBUG', false);
// Obtém todas as variáveis carregadas
$todasVariaveisDeAmbiente = Ambivar::obterTodas();
// Define APP_ENV como 'production' no arquivo .env padrão
Ambivar::adicionar('APP_ENV', 'production');
// Define DEBUG como 'true' em um arquivo específico
Ambivar::adicionar('DEBUG', 'true', __DIR__ . '/.env.dev');
// Define múltiplas variáveis e retorna o número de variáveis definidas com sucesso
$contador = Ambivar::setMany([
'APP_NAME' => 'Minha Aplicação',
'APP_ENV' => 'production',
'APP_DEBUG' => 'false',
'APP_URL' => 'https://example.com'
]);
// Remove a variável TEMP_TOKEN do arquivo .env padrão
Ambivar::remover('TEMP_TOKEN');
// Remove a variável DEBUG de um arquivo específico
Ambivar::remover('DEBUG', __DIR__ . '/.env.test');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.