Last active
March 15, 2018 21:17
-
-
Save ptflp/71e557dbc6e63ccb99133dbf85c33dc0 to your computer and use it in GitHub Desktop.
install yii2 for ptflp/yii2 dockerized Yii2-application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
if (defined('STDIN')) { | |
$hostdb = $argv[1]; | |
$dbname = $argv[2]; | |
$userdb = $argv[3]; | |
$passdb = $argv[4]; | |
} | |
$servername = $hostdb; | |
$username = $userdb; | |
$password = $passdb; | |
// Create connection | |
$conn = new mysqli($servername, $username, $password); | |
// Check connection | |
if ($conn->connect_error) { | |
die("Connection failed: " . $conn->connect_error); | |
} | |
// Create database | |
$sql = "CREATE DATABASE IF NOT EXISTS ".$dbname." CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"; | |
if ($conn->query($sql) === TRUE) { | |
echo "Database created successfully"; | |
} else { | |
echo "Error creating database: " . $conn->error; | |
} | |
$conn->close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
read -p "Type ip/host MySQL database: " -r | |
export hostdb=$REPLY; | |
read -p "Type MySQL database name: " -r | |
export dbname=$REPLY; | |
read -p "Type user of MySQL database: " -r | |
export userdb=$REPLY; | |
read -p "Type password of MySQL database: " -r | |
export passdb=$REPLY; | |
composer create-project --prefer-dist yiisoft/yii2-app-advanced web | |
cd web | |
./init --env=Development --overwrite=All | |
sed -i "s/mysql:host=localhost;dbname=yii2advanced/mysql:host=${hostdb};dbname=${dbname}/" common/config/main-local.php; | |
sed -i "s/'username' => 'root'/'username' => '${userdb}'/" common/config/main-local.php; | |
sed -i "s/'password' => ''/'password' => '${passdb}'/" common/config/main-local.php; | |
url=https://gist.githubusercontent.com/ptflp/71e557dbc6e63ccb99133dbf85c33dc0/raw/be1ff02c376df068e6c6b601dee4eec86eaed68c/initdb | |
filename=$(basename "$url") | |
wget "$url" | |
chmod +x $filename | |
./$filename $hostdb $dbname $userdb $passdb | |
url=https://gist.githubusercontent.com/ptflp/4d4cb63b52b61f2a02b68b9b429b4e94/raw/7ebd54bd0923f7ea8287be2350c8bc0c6f828a1e/yii2-user.sh | |
filename=$(basename "$url") | |
wget "$url" | |
chmod +x $filename | |
./$filename | |
rm -f $filename | |
url2=https://gist.githubusercontent.com/ptflp/50ccdae9895aac97d871676928d6fbbf/raw/d9a568b3799c73ca5b04019ab737ed94774cd32d/.htaccess | |
filename=$(basename "$url2") | |
wget "$url2" | |
cp $filename frontend/web/ | |
mv $filename backend/web/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment