User tests: Successful: Unsuccessful:
Pull Request for Issue #36898 .
Alternative to PR #45523 .
This is complete (I hope) implementation of environment variables in Joomla.
This version uses Symfony\Dotenv component which have an ability to use php file for the environment variables caching. Which should improve security and boot speed. Also provides CLI commands for dump .env to php file, and for debugging of existing variables.
Compared to vlucas/phpdotenv used in #45523 Symfony\Dotenv lacks of customization (like custom Parser etc) but we probably will not bee need it any time soon.
Key points:
.env (or .env.local.php) in root folder to enable it. Or for CLI run command as JOOMLA_ENV=test php cli/joomla.php foobar-comandJOOMLA_ENV is prod. In this state .env file is not allowed and must be used .env.local.php instead. During installation of prod environment installer will dump .env to .env.local.php and remove .env.New CLI commands:
php cli/joomla.php config-dotenv:dump compiles .env files into a PHP-optimized file .env.local.phpphp cli/joomla.php config-dotenv:debug displays all the environment variables configured by dotenv..env with DB options:JOOMLA_DB_TYPE="mysql"
JOOMLA_DB_HOST="Your DB host"
JOOMLA_DB_USER="Your DB user"
JOOMLA_DB_PASSWORD="Your DB password"
JOOMLA_DB_NAME="Your db name"
JOOMLA_DB_PREFIX="DB prefix"
And run installer. You should be asked for Site name, and User information.
Then installation should be completed, as usual.
.env with all installation parameters and user information:JOOMLA_DB_TYPE="mysql"
JOOMLA_DB_HOST="Your DB host"
JOOMLA_DB_USER="Your DB user"
JOOMLA_DB_PASSWORD="Your DB password"
JOOMLA_DB_NAME="Your db name"
JOOMLA_DB_PREFIX="DB prefix"
JOOMLA_SITE_NAME="Test installation"
JOOMLA_PUBLIC_FOLDER=""
JOOMLA_ADMIN_USER="Your admin user"
JOOMLA_ADMIN_USERNAME="Your admin username"
JOOMLA_ADMIN_PASSWORD="Your admin user password"
JOOMLA_ADMIN_EMAIL="Your admin user email"
And run installer. You will not be asked for Site name, and User information.
The installation should be completed, as usual.
Create .env.local.php with DB options, and copy options from configuration.php.
(skip this step if the site was installed with use of .env)
<?php
return [
'JOOMLA_DB_TYPE' => 'mysql',
'JOOMLA_DB_HOST' => 'Your DB host',
'JOOMLA_DB_USER' => 'Your DB user',
'JOOMLA_DB_PASSWORD' => 'Your DB password',
'JOOMLA_DB_NAME' => 'Your db name',
'JOOMLA_DB_PREFIX' => 'DB prefix',
];Then visit the site, all should work as before.
Please select:
| Status | New | ⇒ | Pending |
| Category | ⇒ | Repository Administration com_config Language & Strings External Library Composer Change Installation JavaScript Libraries |
| Labels |
Added:
Feature
Language Change
Composer Dependency Changed
PR-6.1-dev
|
||