A bash script that will install symfony for you
This commit is contained in:
parent
d6a6bd6203
commit
8af889616f
@ -1,11 +1,12 @@
|
|||||||
# symfony
|
# symfony
|
||||||
|
|
||||||
## Two line setup
|
I needed a faster install (don't do anything twice).
|
||||||
|
|
||||||
Just change "YOUR_PROJECT_NAME" to whatever you want.
|
Just change "YOUR_PROJECT_NAME" to whatever you want.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
wget fbot.co/nysymfony
|
wget fbot.co/nysymfony
|
||||||
bash nysymfony YOUR_PROJECT_NAME
|
bash nysymfony YOUR_PROJECT_NAME
|
||||||
rm nysymfony
|
rm nysymfony
|
||||||
|
cd YOUR_PROJECT_NAME
|
||||||
|
sudo docker-compose up -d
|
||||||
```
|
```
|
108
bash/newProject.bash
Normal file
108
bash/newProject.bash
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
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.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 components
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
composer require symfony/process
|
||||||
|
composer require asset
|
||||||
|
composer require annotations
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Docker
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# 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 'DBHOST=mariadb' >> .env
|
||||||
|
GEN=`echo $RANDOM | md5sum | head -c 12`
|
||||||
|
echo "MYSQL_ROOT_PASSWORD=${GEN}" >> .env
|
||||||
|
GEN=`echo $RANDOM | md5sum | head -c 12`
|
||||||
|
echo "DBPASSWORD=${GEN}" >> .env
|
||||||
|
echo 'MYSQL_DATABASE=theapp' >> .env
|
||||||
|
GEN=`echo $RANDOM | md5sum | head -c 4`
|
||||||
|
echo "MYSQL_DATABASE=theuser${GEN}" >> .env
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Instructions
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
echo "Symfony Installed"
|
||||||
|
echo "sudo docker-compose up -d"
|
||||||
|
echo "For more, go to: https://www.nickyeoman.com"
|
||||||
|
|
@ -1,88 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
echo "*** Starting New Symfony Project ***"
|
|
||||||
|
|
||||||
# TODO: check if script has already been run
|
|
||||||
# TODO: check that $1 exits
|
|
||||||
# TODO: check folder doesn't exist
|
|
||||||
|
|
||||||
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
|
|
||||||
mkdir $1
|
|
||||||
cd $1
|
|
||||||
composer require nickyeoman/phpframework
|
|
||||||
echo "Composer has installed nickyeoman/phpframework to $1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# Create directories
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
echo "Creating directories: controllers tmp public views scripts"
|
|
||||||
mkdir -p controllers tmp migrations sass scripts helpers
|
|
||||||
mkdir -p public/css public/js public/images
|
|
||||||
mkdir -p views/modules views/layout views/user
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# Public Folder
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
echo "Creating index.php page in public directory"
|
|
||||||
cp vendor/nickyeoman/phpframework/public/index.php public/.
|
|
||||||
|
|
||||||
echo "Adding Apache htaccess"
|
|
||||||
cp vendor/nickyeoman/phpframework/public/htaccess public/.htaccess
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# Twig
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
echo "Creating scaffolding Twig templates in views directory"
|
|
||||||
cp vendor/nickyeoman/phpframework/twig/head.html.twig views/modules/head.html.twig
|
|
||||||
cp vendor/nickyeoman/phpframework/twig/master.html.twig views/layout/master.html.twig
|
|
||||||
cp vendor/nickyeoman/phpframework/twig/footer.html.twig views/modules/footer.html.twig
|
|
||||||
cp vendor/nickyeoman/phpframework/twig/nav.html.twig views/modules/nav.html.twig
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# SASS
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
echo "Creating SASS directory for css"
|
|
||||||
cp vendor/nickyeoman/phpframework/sass/project.sass sass/.
|
|
||||||
touch sass/variables.sass
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# Configuration
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
echo "Setting up sample .env in root directory. Please edit .env file for your needs."
|
|
||||||
cp vendor/nickyeoman/phpframework/env.sample .env
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# Docker
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
echo "Creating a sample Dockerfile incase you would like to use docker with this project"
|
|
||||||
cp vendor/nickyeoman/phpframework/docker/Dockerfile Dockerfile
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# Creating the first controller
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
bash vendor/nickyeoman/phpframework/bin/newController.bash index
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# Instructions
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
echo "*** End New Project Script ***"
|
|
||||||
|
|
||||||
echo "FURTHER INSTRUCTIONS: "
|
|
||||||
echo "To start a local server, edit .env file then run:"
|
|
||||||
echo "bash vendor/nickyeoman/phpframework/bin/startServer.bash"
|
|
8
twig/twig.yaml
Normal file
8
twig/twig.yaml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
twig:
|
||||||
|
default_path: '%kernel.project_dir%/templates'
|
||||||
|
paths:
|
||||||
|
'%kernel.project_dir%/vendor/nickyeoman/nytwig/src': 'nytwig'
|
||||||
|
|
||||||
|
when@test:
|
||||||
|
twig:
|
||||||
|
strict_variables: true
|
Reference in New Issue
Block a user