Skip to content

Instantly share code, notes, and snippets.

@chanmix51
Last active August 29, 2015 13:56
Show Gist options
  • Save chanmix51/9192161 to your computer and use it in GitHub Desktop.
Save chanmix51/9192161 to your computer and use it in GitHub Desktop.
Create a working Pomm & Silex sandbow in a minute
#!/bin/bash
echo "Postgresql setup";
echo -n "What is your Postgresql username [$USER]:> ";
read db_username;
echo -n "What is this user's password (empty if none) [] :> ";
read db_password;
echo -n "What is the server address (IP address or socket directory [localhost] :> ";
read db_host;
echo -n "What is the server port [5432] :> ";
read db_port;
echo -n "What is the database name [$USER] :> ";
read db_name;
echo -n "What IP address should PHP stand alone be bound on ? (enter 'none' to skip server start) [localhost] :> ";
read php_host;
if [ "$php_host" != "none" ];
then
echo -n "What port should be used for standalone PHP server ? [1025] :> ";
read php_port;
php_port=${php_port:-"1025"};
php_host=${php_host:-"localhost"};
fi;
db_username=${db_username:-$USER};
db_host=${db_host:-"localhost"};
db_password=${db_password:+":${db_password}"};
db_port=${db_port:-"5432"};
db_name=${db_name:=$USER};
if echo "$db_host" | grep "/" > /dev/null;
then
db_host="!${db_host}!";
fi;
wget -O - 'https://gist.github.com/chanmix51/3402026/download' 2>/dev/null |tar xzO |bash;
wget -O - 'http://getcomposer.org/installer' 2>/dev/null |php;
php composer.phar install;
cat > sources/config/config.php << EOF;
<?php
\$app['config.pomm.dsn'] = array('dev' => array('my_db' => array('dsn' => 'pgsql://${db_username}${db_password}@${db_host}:${db_port}/${db_name}', 'name' => 'sandbox')));
EOF
if [ "$php_host" != "none" ];
then
php -S ${php_host}:${php_port} -t web web/index.php &
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment