User tests: Successful: Unsuccessful:
Pull Request for Issue #36898.
This is a reopened version of PR #44894. I can't reopen the #44894 for technical reasons, sorry 😱
This PR adds an ability to configure Joomla using environment variables. To do this, the config provider has been changed to load all environment variables whose names start with JOOMLA_
(e.g. JOOMLA_DEBUG
, JOOMLA_PASSWORD
) and merge them into the config
service.
Also, environment variables can be loaded from .env
files, thankfully to symfony/dotenv.
Create .env
file in the site's root directory
Set environment variables (inside the .env
file):
JOOMLA_OFFLINE=1
JOOMLA_OFFLINE_MESSAGE='Joomla!'
Reload site's home page and ensure that site is offline and the Joomla!
message is shown
Run the following command and ensure that the output is true
:
cli/joomla.php config:get offline
Run the following command and ensure that the output is Joomla!
:
cli/joomla.php config:get offline_message
All should work.
All should work.
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org: joomla/Manual#432
No documentation changes for manual.joomla.org needed
The 12-factor app methodology recommends to store config in the environment.
Also, it makes Joomla more cloud-friendly and simplifies running it inside containers.
For example, using environment variables it's very easy to configure separate database for testing:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/Unit/bootstrap.php" colors="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Integration">
<directory suffix="Test.php">./tests/Integration</directory>
</testsuite>
</testsuites>
<php>
<env name="JOOMLA_DBHOST" value="localhost" force="true"/>
<env name="JOOMLA_DBNAME" value="joomla_test" force="true" />
<env name="JOOMLA_DBUSER" value="joomla_test_user" force="true" />
<env name="JOOMLA_DBPASSWORD" value="joomla_test_password" force="true" />
</php>
</phpunit>
Status | New | ⇒ | Pending |
Category | ⇒ | Administration External Library Composer Change Installation Libraries Unit Tests |
Labels |
Added:
Unit/System Tests
Composer Dependency Changed
PR-6.0-dev
|
Category | Administration External Library Composer Change Installation Libraries Unit Tests | ⇒ | Administration Repository NPM Change JavaScript External Library Composer Change Installation Libraries Unit Tests |
Labels |
Added:
NPM Resource Changed
|
Category | Administration External Library Composer Change Installation Libraries Unit Tests Repository NPM Change JavaScript | ⇒ | Administration External Library Composer Change Installation Libraries Unit Tests |
Labels |
Removed:
NPM Resource Changed
|
I have tested this item ✅ successfully on 0f39e4e
Tested the PR and it works as expected. Environment variable support is successfully integrated, and no issues were encountered. This enhancement improves flexibility in configuration.
@voronkovich Great work!
I have tested this item ✅ successfully on 0f39e4e
I have test this PR successfully. Really cool @voronkovich.
( I don't understand however the logic of wanting to keep the installation folder after installation though, it seems like an unnecessary potential security risk )
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45070.