Skip to content

Commit

Permalink
Init.
Browse files Browse the repository at this point in the history
  • Loading branch information
seanpotts committed Mar 8, 2023
0 parents commit d2f5f0b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# wp-env-heroku-stackhero-mysql
10 changes: 10 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "frc/wp-env-heroku-stackhero-mysql",
"license": "MIT",
"type": "library",
"description": "Export Heroku Stackhero MySQL addon configuration for WordPress.",
"keywords": ["Heroku", "WordPress", "Stackhero", "MySQL"],
"autoload": {
"files": [ "src/stackhero-mysql.php" ]
}
}
40 changes: 40 additions & 0 deletions src/stackhero-mysql.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
namespace Frc\WP\Env\Heroku\StackheroMYSQL;

// Database Host
// ----------------------------------------------------------------
if (getenv('STACKHERO_MYSQL_HOST')):
$databaseHost = parse_url(getenv('STACKHERO_MYSQL_HOST'));
putenv('DB_HOST=' . $databaseHost['path']);
else:
putenv('DB_HOST=localhost');
endif;

// Database Port
// ----------------------------------------------------------------
if (getenv('STACKHERO_MYSQL_PORT')):
putenv('DB_PORT=' . getenv('STACKHERO_MYSQL_PORT'));
endif;

// Database User
// ----------------------------------------------------------------
if (getenv('STACKHERO_MYSQL_USER')):
$databaseUser = parse_url(getenv('STACKHERO_MYSQL_USER'));
putenv('DB_USER=' . $databaseUser['path']);
else:
putenv('DB_USER=root');
endif;

// Database Password
// ----------------------------------------------------------------
if (getenv('STACKHERO_MYSQL_PASSWORD')):
$databasePassword = parse_url(getenv('STACKHERO_MYSQL_PASSWORD'));
putenv('DB_PASSWORD=' . $databasePassword['path']);
endif;

// Database Name
// ----------------------------------------------------------------
if (getenv('STACKHERO_MYSQL_DATABASE_NAME')):
$databaseName = parse_url(getenv('STACKHERO_MYSQL_DATABASE_NAME'));
putenv('DB_NAME=' . $databaseName['path']);
endif;

0 comments on commit d2f5f0b

Please sign in to comment.