Skip to content

Instantly share code, notes, and snippets.

@AydinHassan
Created October 9, 2014 09:24
Show Gist options
  • Save AydinHassan/4096b97e26be4ed99797 to your computer and use it in GitHub Desktop.
Save AydinHassan/4096b97e26be4ed99797 to your computer and use it in GitHub Desktop.
<?php
use Jh\DevSiteTool\Entity\HtPasswdUser;
require __DIR__ . "/vendor/autoload.php";
$sites = [
'site-name' => [
'name' => 'site-name',
'systemUser' => 'site-name',
'systemPassword' => 'userPass',
'databaseUser' => 'site_name',
'databasePassword' => 'dbPass',
'siteLocation' => '/websites/dev.wearejh.com/site-name',
'webServer' => 'apache2',
'projectType' => 'beanstalk',
'environments' => [
'dev' => [
'name' => 'dev',
'dbName' => 'dev_site_name',
'hostFileLocation' => '/etc/apache2/sites-available/site-name.dev.wearejh.com.conf',
'url' => 'http://site-name.dev.wearejh.com/',
],
'staging' => [
'name' => 'staging',
'dbName' => 'staging_site_name',
'hostFileLocation' => '/etc/apache2/sites-available/site-name.staging.wearejh.com.conf',
'url' => 'http://site-name.staging.wearejh.com/',
],
'static' => [
'name' => 'static',
'hostFileLocation' => '/etc/apache2/sites-available/site-name.static.wearejh.com.conf',
'url' => 'http://site-name.static.wearejh.com/',
],
],
'users' => [
[
'userName' => 'htUser',
'password' => 'htPass'
]
],
'htPasswordLocation' => '/websites/dev.wearejh.com/site-name/.htpasswd'
],
];
$repository = new \Jh\DevSiteTool\Repository\FileSiteRepository(__DIR__);
foreach ($sites as $site) {
$siteObj = new \Jh\DevSiteTool\Entity\Site();
$siteObj->setName($site['name']);
$siteObj->setSystemUser($site['systemUser']);
$siteObj->setSystemPassword($site['systemPassword']);
$siteObj->setDatabaseUser($site['databaseUser']);
$siteObj->setDatabasePassword($site['databasePassword']);
$siteObj->setSiteLocation($site['siteLocation']);
$siteObj->setWebServer($site['webServer']);
$siteObj->setProjectType($site['projectType']);
if (isset($site['htPasswordLocation'])) {
$siteObj->setHtPasswdFileLocation($site['htPasswordLocation']);
}
foreach ($site['environments'] as $env) {
$dev = new \Jh\DevSiteTool\Entity\Environment();
$dev->setEnvironment($env['name']);
if (isset($env['dbName'])) {
$dev->setDbName($env['dbName']);
}
$dev->setHostFileLocation($env['hostFileLocation']);
$dev->setUrl($env['url']);
$siteObj->addEnvironment($dev);
}
foreach ($site['users'] as $user) {
$ht = new HtPasswdUser();
$ht->setUserName($user['userName']);
$ht->setPassword($user['password']);
$siteObj->addHtPasswdUser($ht);
}
$repository->add($siteObj->getName(), $siteObj);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment