Skip to content

Conversation

@voronkovich
Copy link
Contributor

@voronkovich voronkovich commented Mar 4, 2025

Pull Request for Issue #36898.

This is a reopened version of PR #44894. I can't reopen the #44894 for technical reasons, sorry 😱

Summary of Changes

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.

Testing Instructions

  1. Create .env file in the site's root directory

  2. Set environment variables (inside the .env file):

    JOOMLA_OFFLINE=1
    JOOMLA_OFFLINE_MESSAGE='Joomla!'
  3. Reload site's home page and ensure that site is offline and the Joomla! message is shown

  4. Run the following command and ensure that the output is true:

    cli/joomla.php config:get offline
  5. Run the following command and ensure that the output is Joomla!:

    cli/joomla.php config:get offline_message

Actual result BEFORE applying this Pull Request

All should work.

Expected result AFTER applying this Pull Request

All should work.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org: [6.0] Article about .env files Manual#432

  • No documentation changes for manual.joomla.org needed

Why?

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>

@joomla-cms-bot joomla-cms-bot added the NPM Resource Changed This Pull Request can't be tested by Patchtester label Mar 4, 2025
@voronkovich voronkovich force-pushed the config-envs branch 2 times, most recently from 476e3bd to f1ab985 Compare March 4, 2025 23:46
@voronkovich voronkovich marked this pull request as draft March 4, 2025 23:47
@joomla-cms-bot joomla-cms-bot removed the NPM Resource Changed This Pull Request can't be tested by Patchtester label Mar 4, 2025
@voronkovich voronkovich force-pushed the config-envs branch 3 times, most recently from aec3851 to 7dfa960 Compare March 5, 2025 00:08
@voronkovich voronkovich marked this pull request as ready for review March 5, 2025 00:15
@exlemor
Copy link

exlemor commented Mar 9, 2025

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.

@krishnaGandhi11
Copy link

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!


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45070.

@alikon
Copy link
Contributor

alikon commented Mar 13, 2025

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45070.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Mar 13, 2025
@Hackwar Hackwar added RMDQ ReleaseManagerDecisionQueue and removed RTC This Pull Request is Ready To Commit labels Mar 15, 2025
@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Mar 15, 2025
@Bodge-IT
Copy link
Contributor

This was reviewed by Maintainers on 16th April. Is the RMDQ label still relevant @Hackwar or are we good to proceed?

@Bodge-IT Bodge-IT removed the RTC This Pull Request is Ready To Commit label May 14, 2025
@Fedik
Copy link
Member

Fedik commented May 24, 2025

I made an alternative PR, with cli and web installation support, and better variable names #45523

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label May 24, 2025
@voronkovich
Copy link
Contributor Author

Closed in favor of #45523

@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants