Skip to content
This repository has been archived by the owner on Oct 14, 2021. It is now read-only.

Latest commit

 

History

History
35 lines (25 loc) · 1.5 KB

readme.md

File metadata and controls

35 lines (25 loc) · 1.5 KB

Joomla for Azure Deploy to Azure

This repository contains Joomla application that can run on Azure app service with both ClearDB and MySQL inapp. If you wish to use MySQL inapp , it is recommended to use Environment variables.

To use Environment variables with Joomla application to pass in the database information , add the following constructor in configuration.php inside JConfig class. To use this with MySQL in app feature, use the $_SERVER['MYSQLCONNSTR_localdb]' variable to get the database connection string.

Add this code to configuration.php file if using MySQL in-app

public function __construct(){
	  $connectstr_dbhost = '';
		$connectstr_dbname = '';
		$connectstr_dbusername = '';
		$connectstr_dbpassword = '';
		foreach ($_SERVER as $key => $value) {
			if (strpos($key, "MYSQLCONNSTR_") !== 0) {
				continue;
			}
			
			$connectstr_dbhost = preg_replace("/^.*Data Source=(.+?);.*$/", "\\1", $value);
			$connectstr_dbname = preg_replace("/^.*Database=(.+?);.*$/", "\\1", $value);
			$connectstr_dbusername = preg_replace("/^.*User Id=(.+?);.*$/", "\\1", $value);
			$connectstr_dbpassword = preg_replace("/^.*Password=(.+?)$/", "\\1", $value);
		}

        $this->user = $connectstr_dbusername;
        $this->host=$connectstr_dbhost;
        $this->password= $connectstr_dbpassword;
        $this->db= $connectstr_dbname;
        
    }