1. Go to this page and download the library: Download tourze/env-manage-bundle 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/ */
use Tourze\EnvManageBundle\Entity\Env;
use Doctrine\ORM\EntityManagerInterface;
$env = new Env();
$env->setName('API_ENDPOINT');
$env->setValue('https://api.example.com');
$env->setValid(true);
$env->setSync(false);
$env->setRemark('External API endpoint');
$entityManager->persist($env);
$entityManager->flush();
// In services
$apiEndpoint = $_ENV['API_ENDPOINT'] ?? 'default';
// Using the service
/** @var \Tourze\EnvManageBundle\Service\EnvService $envService */
$publicVars = $envService->fetchPublicArray();
// In Twig templates
{{ env_value('API_ENDPOINT') }}
use Tourze\EnvManageBundle\Service\EnvService;
class MyEnvService implements EnvService
{
public function fetchPublicArray(): array
{
// Custom logic for public variables
}
}
// Expose environment variables via JSON-RPC
$procedure = new GetEnvConfig($envService);
$result = $procedure->execute();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.