I'm running Joomla under Azure using the MySQL In-App option for the database. Everything has gone well, but I have been unable to get the database config variables in JConfig to pull dynamically from the MYSQLCONNSTR_localdb environment variable.

I've tried the MS suggested solution posted here https://blogs.msdn.microsoft.com/azureossds/2016/12/09/mysql-in-app-configuration-for-php-content-management-systems/, and have tried various ways of extracting the information from the environment variable and setting the variables to the results, all with no success. The only thing that seems to be working is hard-coding the host address which is .. problematic.

An example might be something like this:

class JConfig {
$hostVar = getenv("MYSQLCONNSTR_localdb");
$hostArray = array();
foreach( explode( ';', $hostVar ) as $substr )
    $asplode = explode('=', $substr);
    $hostArray[ $asplode[0] ] = $asplode[1];
public $host = $hostArray['Data Source'];

So far all variations from the hard-coded address have been 'Error.' on the front end.

  • May I ask what exact you are getting from var_export($hostVar);? I prefer to strip all processes back to isolate the earliest failing aspect. Please edit your question when you have this vital detail. We are also going to need a bit more detail than Error; please switch on debugging mode, check your logs, etc. and give us something to chew on. – mickmackusa May 22 '19 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.