diff --git a/config.php.sample b/config.php.sample
index 667afe2e..41b09247 100755
--- a/config.php.sample
+++ b/config.php.sample
@@ -4,4 +4,5 @@ define('PSM_DB_USER', 'db_user');
define('PSM_DB_PASS', 'db_pass');
define('PSM_DB_NAME', 'db_name');
define('PSM_DB_HOST', 'localhost');
+define('PSM_DB_PORT', '3306');
diff --git a/docs/install.rst b/docs/install.rst
index f8e0efa2..627704fb 100644
--- a/docs/install.rst
+++ b/docs/install.rst
@@ -27,6 +27,7 @@ To change these values correctly, only update the second parameter of the functi
define('PSM_DB_NAME', 'db_name');
define('PSM_DB_USER', 'db_user');
define('PSM_DB_PASS', 'db_user_password');
+ define('PSM_DB_PORT', '3306');
For example: to change your username you should ONLY change the 'db\_user' part.
Do NOT remove the quotes around your username as that will result in an error.
diff --git a/puphpet/files/exec-once/psminstall.sh b/puphpet/files/exec-once/psminstall.sh
index 2ebd8b54..b115800f 100644
--- a/puphpet/files/exec-once/psminstall.sh
+++ b/puphpet/files/exec-once/psminstall.sh
@@ -6,8 +6,9 @@ define('PSM_DB_USER', 'psm'); \
define('PSM_DB_PASS', 'psm'); \
define('PSM_DB_NAME', 'psm'); \
define('PSM_DB_HOST', 'localhost'); \
+define('PSM_DB_PORT', '3306'); \
?>" > /var/www/default/psm/config.php
echo "" > /var/www/default/index.php
\ No newline at end of file
+?>" > /var/www/default/index.php
diff --git a/src/config/services.xml b/src/config/services.xml
index 5d3fbd1b..43446dcd 100644
--- a/src/config/services.xml
+++ b/src/config/services.xml
@@ -18,6 +18,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/sc
%path.src%templates
PSM_DB_HOST
+ PSM_DB_PORT
PSM_DB_USER
PSM_DB_PASS
PSM_DB_NAME
@@ -38,6 +39,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/sc
%db.user%
%db.pass%
%db.name%
+ %db.port%
diff --git a/src/psm/Module/Install/Controller/InstallController.php b/src/psm/Module/Install/Controller/InstallController.php
index dad31b14..75a7e94a 100644
--- a/src/psm/Module/Install/Controller/InstallController.php
+++ b/src/psm/Module/Install/Controller/InstallController.php
@@ -121,6 +121,7 @@ class InstallController extends AbstractController {
$config = array(
'host' => 'localhost',
+ 'port' => '3306',
'name' => '',
'user' => '',
'pass' => '',
@@ -143,7 +144,8 @@ class InstallController extends AbstractController {
$config['host'],
$config['user'],
$config['pass'],
- $config['name']
+ $config['name'],
+ $config['port']
);
if($this->db->status()) {
@@ -307,6 +309,7 @@ class InstallController extends AbstractController {
'pass' => '',
'name' => '',
'host' => '',
+ 'port' => '3306'
);
$pattern = "/define\('SM_DB_{key}', '(.*?)'/u";
diff --git a/src/psm/Service/Database.php b/src/psm/Service/Database.php
index c5296170..16ff69fc 100644
--- a/src/psm/Service/Database.php
+++ b/src/psm/Service/Database.php
@@ -35,6 +35,12 @@ class Database {
*/
protected $db_host;
+ /**
+ * DB port
+ * @var string $db_port
+ */
+ protected $db_port = 3306;
+
/**
* DB name
* @var string $db_name
@@ -81,9 +87,10 @@ class Database {
* @param string $pass
* @param string $db
*/
- function __construct($host = null, $user = null, $pass = null, $db = null) {
+ function __construct($host = null, $user = null, $pass = null, $db = null, $port = null) {
if($host != null && $user != null && $pass !== null && $db != null) {
$this->db_host = $host;
+ $this->db_port = $port || 3306;
$this->db_name = $db;
$this->db_user = $user;
$this->db_pass = $pass;
@@ -498,7 +505,7 @@ class Database {
// Initizale connection
try {
$this->pdo = new \PDO(
- 'mysql:host='.$this->db_host.';dbname='.$this->db_name.';charset=utf8',
+ 'mysql:host='.$this->db_host.';port='.$this->db_port.';dbname='.$this->db_name.';charset=utf8',
$this->db_user,
$this->db_pass
);
diff --git a/src/templates/default/module/install/config_new.tpl.html b/src/templates/default/module/install/config_new.tpl.html
index 64fe07ab..4a07a4ce 100644
--- a/src/templates/default/module/install/config_new.tpl.html
+++ b/src/templates/default/module/install/config_new.tpl.html
@@ -17,6 +17,12 @@
+
@@ -60,4 +66,4 @@
{% endif %}
-{% endblock %}
\ No newline at end of file
+{% endblock %}