Skip to content

Conversation

@Fedik
Copy link
Member

@Fedik Fedik commented May 24, 2025

Pull Request for Issue #36898 .

Alternative to PR #45070 .

Summary of Changes

This is complete (I hope) implementation of environment variables in Joomla.

Key points:

  • By default the feature is disabled. Create .env in root folder to enable it (can be just an empty file).
  • I tried to keep the variable names in sync with Joomla Docker. If you find something is missing or a typo, please let me know.
  • The installation can be completed with environment variables (except language part). This work with CLI and WEB installer. User can provide all options via environment variables (including admin user info) or a few (like DB only, then installer will ask for missing options).
  • The configuration options provided by environment variables cannot be edited in backend, also via CLI.

Testing Instructions

Test installation, test with Web and in CLI installer

  1. Create .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.

  1. Create .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.

Test the existing site

Create .env with DB options, and copy options from configuration.php.
(skip this step if the site was installed with use of .env)

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.

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: TBD
  • No documentation changes for manual.joomla.org needed

@Llewellynvdm please have a look if it will be good with Joomla Docker, thanks!

@dautrich
Copy link

dautrich commented Aug 15, 2025

I tried with the new prebuilt package. Same issue. See Screenshot:

Bildschirminhalt erfassen-1

The error message means "Path not found".

@brianteeman
Copy link
Contributor

I have tested this item ✅ successfully on ce36cf3


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

@brianteeman
Copy link
Contributor

tested using git branch - all worked fine

BUT
I noticed that you are making a change to htaccess.txt
In the past we have always done a post-installation message for changed htaccess.txt but maybe in this case it will be enough to document it in the manual (@SniperSister any thoughts?)

Co-authored-by: Richard Fath <richard67@users.noreply.github.com>
@Fedik
Copy link
Member Author

Fedik commented Aug 16, 2025

I noticed that you are making a change to htaccess.txt

It is not critical for existing websites. Only for new and who decide to use to env. For this the documentation should be enough. I will do it later.

@dautrich I think it something with Laragon, does CLI installation for latest Joomla! 6 nightly build works for you without this error?

@dautrich
Copy link

@Fedik I will try a CLI installation of the newest nightly build under Laragon today.

@dautrich
Copy link

@Fedik I get the same issue with a Nightly Build of 6.0. Therefore, the issue seems to be related to my Laragon environment. Unfortunately, I don't have on online test site at hand at the moment.

@Fedik
Copy link
Member Author

Fedik commented Aug 16, 2025

@dautrich no problem, thank you for checking

@brianteeman
Copy link
Contributor

fyi my tests were with laragon 8

@dautrich
Copy link

fyi I use Laragon 6

@dautrich
Copy link

I have tested this item ✅ successfully on ce36cf3


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

@richard67
Copy link
Member

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Aug 18, 2025
@brianteeman
Copy link
Contributor

@dautrich what changed to make it work?

@dautrich
Copy link

dautrich commented Aug 18, 2025

@brianteeman
I tested the CLI part on the Internet (not locally via Laragon). The resulting site is still online under upgrade.hasenritter.de

grafik

@brianteeman
Copy link
Contributor

Ok. Must have been a local config issue with your laragon 6 instance

@richard67
Copy link
Member

I've allowed myself to fix the conflict in the composer.lock file by updating the content hash with composer update --lock.

@HLeithner HLeithner changed the base branch from 6.0-dev to 6.1-dev August 31, 2025 11:57
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 6.1-dev.

@HLeithner HLeithner changed the title [6.0] Variables from non natural environment [6.1] Variables from non natural environment Aug 31, 2025
@tecpromotion
Copy link
Contributor

@Fedik We would like to have this in 6.1. Can you please resolve the conflict? Thank you very much.

Copy link
Member

@HLeithner HLeithner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I talked to @SniperSister and we would like to request some changes:

  • checking for an JOOMLA_ENVIRONMENT environment variable
  • instead check that a .env file exists (always even if it's empty) to use $_ENV
  • and .env file is not in JPATH_PUBLIC

This increases the security by using the public folder feature and allow to make people more aware of it.
Also it makes it "impossible" to extract any .env.* file per direct browser request

Another thing I would like to request is to follow the .env naming semantic used by symfony and mentioned by @voronkovich in this comment
and in this comment

would be great if you can update the pr so we can get it ready for 6.1

 Conflicts:
	administrator/components/com_config/src/Model/ApplicationModel.php
	composer.lock
@Fedik
Copy link
Member Author

Fedik commented Nov 30, 2025

JOOMLA_ENVIRONMENT already there.
Also with it we no need naming semantic because target file can be set with this variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Composer Dependency Changed Feature Language Change This is for Translators PR-6.1-dev RTC This Pull Request is Ready To Commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants