Skip to content

Commit d2f5f0b

Browse files
committed
Init.
0 parents  commit d2f5f0b

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# wp-env-heroku-stackhero-mysql

composer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "frc/wp-env-heroku-stackhero-mysql",
3+
"license": "MIT",
4+
"type": "library",
5+
"description": "Export Heroku Stackhero MySQL addon configuration for WordPress.",
6+
"keywords": ["Heroku", "WordPress", "Stackhero", "MySQL"],
7+
"autoload": {
8+
"files": [ "src/stackhero-mysql.php" ]
9+
}
10+
}

src/stackhero-mysql.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
namespace Frc\WP\Env\Heroku\StackheroMYSQL;
3+
4+
// Database Host
5+
// ----------------------------------------------------------------
6+
if (getenv('STACKHERO_MYSQL_HOST')):
7+
$databaseHost = parse_url(getenv('STACKHERO_MYSQL_HOST'));
8+
putenv('DB_HOST=' . $databaseHost['path']);
9+
else:
10+
putenv('DB_HOST=localhost');
11+
endif;
12+
13+
// Database Port
14+
// ----------------------------------------------------------------
15+
if (getenv('STACKHERO_MYSQL_PORT')):
16+
putenv('DB_PORT=' . getenv('STACKHERO_MYSQL_PORT'));
17+
endif;
18+
19+
// Database User
20+
// ----------------------------------------------------------------
21+
if (getenv('STACKHERO_MYSQL_USER')):
22+
$databaseUser = parse_url(getenv('STACKHERO_MYSQL_USER'));
23+
putenv('DB_USER=' . $databaseUser['path']);
24+
else:
25+
putenv('DB_USER=root');
26+
endif;
27+
28+
// Database Password
29+
// ----------------------------------------------------------------
30+
if (getenv('STACKHERO_MYSQL_PASSWORD')):
31+
$databasePassword = parse_url(getenv('STACKHERO_MYSQL_PASSWORD'));
32+
putenv('DB_PASSWORD=' . $databasePassword['path']);
33+
endif;
34+
35+
// Database Name
36+
// ----------------------------------------------------------------
37+
if (getenv('STACKHERO_MYSQL_DATABASE_NAME')):
38+
$databaseName = parse_url(getenv('STACKHERO_MYSQL_DATABASE_NAME'));
39+
putenv('DB_NAME=' . $databaseName['path']);
40+
endif;

0 commit comments

Comments
 (0)