Skip to content

Instantly share code, notes, and snippets.

@mtthlm
Last active December 11, 2017 20:31
Show Gist options
  • Save mtthlm/4a7a0b99f6ddef20f348 to your computer and use it in GitHub Desktop.
Save mtthlm/4a7a0b99f6ddef20f348 to your computer and use it in GitHub Desktop.
A little script to cleanup a Laravel installation
#!/usr/bin/env bash
DIRECTORY=$1
echo ""
if [[ ! -f "${DIRECTORY}/.php_cs" ]]; then
echo -e -n "\033[33m- Downloading PHP-CS-Fixer configuration file...\033[0m"
curl --output "${DIRECTORY}/.php_cs" --silent https://gist.githubusercontent.com/mtthlm/11353191/raw/d6fb1608b0bc7994ee1f8bd15f4a0f30e83ccc91/.php_cs
echo -e "\033[33m Done.\033[0m"
fi
echo -e -n "\033[33m- Running PHP-CS-Fixer...\033[0m"
php-cs-fixer fix --quiet "${DIRECTORY}" > /dev/null &2>&1
echo -e "\033[33m Done.\033[0m"
FILES=( "/app/controllers/HomeController.php" "/app/database/production.sqlite" "/app/tests/ExampleTest.php" "/app/views/hello.php" "/CONTRIBUTING.md" "/readme.md" )
for FILE in "${FILES[@]}"
do
if [[ -f "${DIRECTORY}${FILE}" ]]; then
echo -e "\033[33m- Removing \"${FILE}\".\033[0m"
rm "${DIRECTORY}${FILE}"
fi
done
echo -e -n "\033[33m- Overwriting \"routes.php\"...\033[0m"
cat > "${DIRECTORY}/app/routes.php" << EOM
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::get('/', function () {
return Response::make("Hello world");
});
EOM
echo -e "\033[33m Done.\033[0m"
echo ""
echo -e "\033[32mSuccessfully cleaned up.\033[0m"
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment