2022-11-14 05:47:29 +00:00
|
|
|
#!/bin/bash
|
2022-11-14 17:07:56 +00:00
|
|
|
################################################################################
|
|
|
|
# Nix install symfony bash script
|
2023-04-11 18:22:23 +00:00
|
|
|
# v2
|
2022-11-14 17:07:56 +00:00
|
|
|
################################################################################
|
2022-11-14 05:47:29 +00:00
|
|
|
|
2023-04-11 18:22:23 +00:00
|
|
|
################################################################################
|
|
|
|
# Check parameter (folder name)
|
|
|
|
################################################################################
|
2022-11-14 05:47:29 +00:00
|
|
|
|
2023-04-11 18:22:23 +00:00
|
|
|
if [ -z "$1" ]
|
|
|
|
then
|
|
|
|
echo "Please provide a folder name"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-11-14 05:47:29 +00:00
|
|
|
[ -d "$1" ] && echo "Folder $1 already exists" && exit 1
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Check composer installed
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
composer -v > /dev/null 2>&1
|
|
|
|
COMPOSER=$?
|
|
|
|
if [[ $COMPOSER -ne 0 ]]; then
|
|
|
|
echo 'Composer is not installed'
|
|
|
|
echo 'Checkout how to Install Composer here: https://www.nickyeoman.com/blog/php/install-composer-on-ubuntu/'
|
|
|
|
echo 'Once installed, try running this script again'
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Composer is installed and ready to go."
|
|
|
|
fi
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Symfony bin installed
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
symfony help > /dev/null 2>&1
|
|
|
|
SYMFONY=$?
|
|
|
|
if [[ $SYMFONY -ne 0 ]]; then
|
|
|
|
echo 'Symfony is not installed'
|
|
|
|
echo 'Do this: https://symfony.com/download'
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
symfony new $1
|
|
|
|
cd $1
|
|
|
|
echo "New symfony project called $1 created."
|
|
|
|
fi
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Create directories
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
echo "Creating directories: sass, scripts"
|
|
|
|
mkdir -p sass scripts
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Twig
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
echo "Creating scaffolding Twig templates in views directory"
|
|
|
|
composer require twig
|
|
|
|
composer require nickyeoman/nytwig
|
|
|
|
mv config/packages/twig.yaml config/packages/twig.yaml.bak
|
2023-04-08 07:26:32 +00:00
|
|
|
wget https://git.nickyeoman.com/nick/symfony/raw/branch/main/twig/twig.yaml
|
2022-11-16 02:33:37 +00:00
|
|
|
mv twig.yaml config/packages/twig.yaml
|
2022-11-14 05:47:29 +00:00
|
|
|
echo "Your twig.yaml config file has been replaced, remove the bak if you are happy."
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# SASS
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
echo "Creating SASS directory for css"
|
2022-12-18 05:11:55 +00:00
|
|
|
composer require nickyeoman/sassLibrary
|
2022-11-14 05:47:29 +00:00
|
|
|
touch sass/$1.sass
|
2022-12-18 05:11:55 +00:00
|
|
|
mkdir -p public/css
|
|
|
|
touch public/css/main.css
|
|
|
|
echo '.sass-cache' >> .gitignore
|
2022-11-14 05:47:29 +00:00
|
|
|
echo '@import ../vendor/nickyeoman/sasslibrary/master.sass' > sass/$1.sass
|
|
|
|
echo "SASS installed you still need to run sass sass/$1.sass public/css/main.css"
|
|
|
|
|
|
|
|
################################################################################
|
2022-11-16 02:33:37 +00:00
|
|
|
# Symfony bundles
|
2022-11-14 05:47:29 +00:00
|
|
|
################################################################################
|
|
|
|
|
2022-12-18 05:11:55 +00:00
|
|
|
composer req nickyeoman/symfonycms
|
2022-11-16 02:33:37 +00:00
|
|
|
composer req symfony/process
|
|
|
|
composer req asset
|
2022-12-14 08:26:38 +00:00
|
|
|
composer req sensio/framework-extra-bundle
|
2022-12-17 22:29:39 +00:00
|
|
|
composer req symfony/mailer
|
2022-11-17 04:02:30 +00:00
|
|
|
|
2022-11-17 22:07:14 +00:00
|
|
|
################################################################################
|
|
|
|
# Symfony development bundles
|
|
|
|
################################################################################
|
2022-11-16 02:33:37 +00:00
|
|
|
|
|
|
|
# Dev components
|
|
|
|
composer req --dev maker
|
2022-11-16 20:43:07 +00:00
|
|
|
composer req --dev symfony/profiler-pack
|
2022-11-16 02:33:37 +00:00
|
|
|
composer req debug logger
|
2022-11-14 05:47:29 +00:00
|
|
|
|
2022-11-17 22:07:14 +00:00
|
|
|
################################################################################
|
|
|
|
# Symfony security
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
composer require symfony/security-bundle
|
|
|
|
composer require form validator
|
|
|
|
composer require symfonycasts/verify-email-bundle
|
|
|
|
|
2022-11-18 01:10:00 +00:00
|
|
|
################################################################################
|
|
|
|
# Database
|
|
|
|
################################################################################
|
|
|
|
|
2023-04-11 18:22:23 +00:00
|
|
|
composer req -n orm --with-all-dependencies
|
|
|
|
sleep 2
|
2022-11-18 01:10:00 +00:00
|
|
|
|
|
|
|
# TODO: In the future you may want to replace this with code
|
|
|
|
# ( but not here if you are sharing the script)
|
|
|
|
# sed -n -e '/^DATABASE_URL/p' .env
|
|
|
|
|
2022-11-14 05:47:29 +00:00
|
|
|
################################################################################
|
|
|
|
# Docker
|
|
|
|
################################################################################
|
|
|
|
|
2022-11-17 22:07:14 +00:00
|
|
|
# For the Apache container
|
2022-11-18 08:06:26 +00:00
|
|
|
composer req symfony/apache-pack
|
|
|
|
#TODO: find a way to trigger this without interaction
|
2022-11-17 22:07:14 +00:00
|
|
|
|
2023-04-11 18:22:23 +00:00
|
|
|
# You need the following variables in your env for docker-compose
|
2022-11-14 05:47:29 +00:00
|
|
|
# You need the following variables in your env for docker-compose
|
|
|
|
echo '' >> .env
|
|
|
|
echo '# For Docker compose' >> .env
|
|
|
|
echo 'DOCKERNAME=symfony' >> .env
|
|
|
|
echo 'DOCKERIMAGE=YOUR_NAME/YOUR_IMAGE_NAME' >> .env
|
|
|
|
echo 'DOCKERVER=latest' >> .env
|
|
|
|
echo 'DOCKERNET=DOCKER_NETWORK_NAME_FOR_PROXY' >> .env
|
2022-11-16 02:33:37 +00:00
|
|
|
echo "DOCKERPORT=8000" >> .env
|
2023-04-11 18:22:23 +00:00
|
|
|
ROOTPASS=`echo $RANDOM | md5sum | head -c 12`
|
|
|
|
echo "MYSQL_ROOT_PASSWORD=${ROOTPASS}" >> .env
|
2022-11-18 01:10:00 +00:00
|
|
|
echo 'DOCKERPHPMYADMIN=8001' >> .env
|
|
|
|
echo '' >> .env
|
2022-11-16 02:33:37 +00:00
|
|
|
echo '# Database info, should match your db url' >> .env
|
2023-04-11 18:22:23 +00:00
|
|
|
DBHOST='mariadb'
|
|
|
|
echo "DBHOST=${DBHOST}" >> .env
|
|
|
|
DB='symfony_project'
|
|
|
|
echo "DB=${DB}" >> .env
|
|
|
|
DBUSER=`echo $RANDOM | md5sum | head -c 4`
|
|
|
|
echo "DBUSER=theuser${DBUSER}" >> .env
|
|
|
|
DBPASS=`echo $RANDOM | md5sum | head -c 12`
|
|
|
|
echo "DBPASSWORD=${DBPASS}" >> .env
|
2022-11-18 01:10:00 +00:00
|
|
|
echo '' >> .env
|
2023-04-11 18:22:23 +00:00
|
|
|
echo "DATABASE_URL=\"mysql://theuser${DBUSER}:${DBPASS}@${DBHOST}:3306/${DB}?serverVersion=mariadb-10.4.11&charset=utf8mb4\"" >> .env
|
2022-11-14 05:47:29 +00:00
|
|
|
|
2022-11-16 02:33:37 +00:00
|
|
|
# TODO: move these here after you have symfony production ready
|
2022-11-18 01:10:00 +00:00
|
|
|
rm docker-compose.yml
|
|
|
|
rm docker-compose.override.yml
|
2022-11-14 05:47:29 +00:00
|
|
|
echo "Creating a docker-compose"
|
|
|
|
wget https://raw.githubusercontent.com/nickyeoman/phpframework/main/docker/docker-compose.yml
|
|
|
|
|
|
|
|
echo "Creating a Dockerfile"
|
|
|
|
wget https://raw.githubusercontent.com/nickyeoman/phpframework/main/docker/Dockerfile
|
|
|
|
|
2023-04-11 04:17:03 +00:00
|
|
|
################################################################################
|
|
|
|
# Routes
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
wget https://git.nickyeoman.com/nick/symfony/raw/branch/main/routes/routes.yaml
|
2023-04-11 18:22:23 +00:00
|
|
|
mv routes.yaml config/routes/symfonycms.yaml
|
2023-04-11 04:17:03 +00:00
|
|
|
|
2022-11-18 04:25:09 +00:00
|
|
|
################################################################################
|
|
|
|
# Clean up
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
composer update
|
|
|
|
|
2022-11-17 04:02:30 +00:00
|
|
|
################################################################################
|
|
|
|
# Git
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
git add .
|
|
|
|
git commit -m"New Project Script Run Completed"
|
|
|
|
|
2022-11-14 05:47:29 +00:00
|
|
|
################################################################################
|
|
|
|
# Instructions
|
|
|
|
################################################################################
|
|
|
|
|
2022-11-16 02:33:37 +00:00
|
|
|
php bin/console --version
|
|
|
|
|
2022-11-18 04:25:09 +00:00
|
|
|
composer recipes
|
2022-11-14 05:47:29 +00:00
|
|
|
|
2022-11-18 04:25:09 +00:00
|
|
|
echo "Symfony Installed"
|