168 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			168 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/bin/bash
 | 
						|
################################################################################
 | 
						|
# Nix install symfony bash script
 | 
						|
# v1.0.0
 | 
						|
################################################################################
 | 
						|
 | 
						|
echo "*** Starting New Symfony Project ***"
 | 
						|
 | 
						|
# check that $1 folder does not exit
 | 
						|
[ -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
 | 
						|
wget https://git.gopo.li/nick/symfony/raw/branch/main/twig/twig.yaml
 | 
						|
mv twig.yaml config/packages/twig.yaml
 | 
						|
echo "Your twig.yaml config file has been replaced, remove the bak if you are happy."
 | 
						|
 | 
						|
################################################################################
 | 
						|
# SASS
 | 
						|
################################################################################
 | 
						|
 | 
						|
echo "Creating SASS directory for css"
 | 
						|
composer require nickyeoman/nytwig
 | 
						|
touch sass/$1.sass
 | 
						|
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"
 | 
						|
 | 
						|
################################################################################
 | 
						|
# Symfony bundles
 | 
						|
################################################################################
 | 
						|
 | 
						|
composer req symfony/process 
 | 
						|
composer req asset 
 | 
						|
composer req sensio/framework-extra-bundle
 | 
						|
 | 
						|
################################################################################
 | 
						|
# Symfony development bundles
 | 
						|
################################################################################
 | 
						|
 | 
						|
# Dev components
 | 
						|
composer req --dev maker
 | 
						|
composer req --dev symfony/profiler-pack
 | 
						|
composer req debug logger
 | 
						|
 | 
						|
################################################################################
 | 
						|
# Symfony security
 | 
						|
################################################################################
 | 
						|
 | 
						|
composer require symfony/security-bundle
 | 
						|
composer require form validator
 | 
						|
composer require symfonycasts/verify-email-bundle
 | 
						|
 | 
						|
################################################################################
 | 
						|
# Database
 | 
						|
################################################################################
 | 
						|
 | 
						|
composer req -n orm && sleep 1
 | 
						|
 | 
						|
# 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
 | 
						|
 | 
						|
################################################################################
 | 
						|
# Docker
 | 
						|
################################################################################
 | 
						|
 | 
						|
# For the Apache container
 | 
						|
composer req symfony/apache-pack
 | 
						|
#TODO: find a way to trigger this without interaction
 | 
						|
 | 
						|
# 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
 | 
						|
echo "DOCKERPORT=8000" >> .env
 | 
						|
GEN=`echo $RANDOM | md5sum | head -c 12`
 | 
						|
echo "MYSQL_ROOT_PASSWORD=${GEN}" >> .env
 | 
						|
echo 'DOCKERPHPMYADMIN=8001' >> .env
 | 
						|
echo '' >> .env
 | 
						|
echo '# Database info, should match your db url' >> .env
 | 
						|
echo 'DBHOST=mariadb' >> .env
 | 
						|
echo 'DB=symfony_project' >> .env
 | 
						|
GEN=`echo $RANDOM | md5sum | head -c 4`
 | 
						|
echo "DBUSER=theuser${GEN}" >> .env
 | 
						|
GEN=`echo $RANDOM | md5sum | head -c 12`
 | 
						|
echo "DBPASSWORD=${GEN}" >> .env
 | 
						|
echo '' >> .env
 | 
						|
echo '# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8&charset=utf8mb4"' >> .env
 | 
						|
 | 
						|
 | 
						|
# TODO: move these here after you have symfony production ready
 | 
						|
rm docker-compose.yml
 | 
						|
rm docker-compose.override.yml
 | 
						|
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
 | 
						|
 | 
						|
################################################################################
 | 
						|
# Clean up
 | 
						|
################################################################################
 | 
						|
 | 
						|
composer update
 | 
						|
 | 
						|
################################################################################
 | 
						|
# Git
 | 
						|
################################################################################
 | 
						|
 | 
						|
git add .
 | 
						|
git commit -m"New Project Script Run Completed"
 | 
						|
 | 
						|
################################################################################
 | 
						|
# Instructions
 | 
						|
################################################################################
 | 
						|
 | 
						|
php bin/console --version
 | 
						|
 | 
						|
composer recipes
 | 
						|
 | 
						|
echo "Symfony Installed" |