Created
January 25, 2018 14:26
-
-
Save hasibomi/4c804249573b71482842cd7260de0452 to your computer and use it in GitHub Desktop.
Command line installation script to setup laravel project after cloning an application from git
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 | |
/** | |
* Install bower dependencies | |
*/ | |
function bowerInstall() { | |
if (! file_exists("app/assets/bower_components")) { | |
try { | |
echo shell_exec("cd app && bower install"); | |
} catch (Exception $e) { | |
echo "Bower could not install dependencies. Reason: {$e->getMessage()}\n"; | |
} | |
} | |
} | |
/** | |
* Install composer dependencies | |
*/ | |
function composerInstall() { | |
if (! file_exists("api/vendor")) { | |
try { | |
echo shell_exec("cd api && composer install"); | |
} catch (Exception $e) { | |
echo "Composer could not install dependencies. Reason: {$e->getMessage()}\n"; | |
} | |
} | |
} | |
/** | |
* Make .env file | |
*/ | |
function makeDotEnv() { | |
if (! file_exists("api/.env")) { | |
if (! copy("api/.env.example", "api/.env")) { | |
echo "Failed to create api/.env file. Reason: api/.env.example file not found\n"; | |
} else { | |
echo "api/.env file initialized.\n"; | |
echo shell_exec("php artisan key:generate\n"); | |
} | |
} | |
} | |
/** | |
* Finally install the application | |
*/ | |
function install() { | |
bowerInstall(); | |
composerInstall(); | |
makeDotEnv(); | |
} | |
install(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment