diff --git a/README.md b/README.md index ba711ff..614dcb5 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ I needed a faster install (don't do anything twice). Just change "YOUR_PROJECT_NAME" to whatever you want. ```bash -wget fbot.co/nysymfony +wget 4lt.ca/nysymfony bash nysymfony YOUR_PROJECT_NAME rm nysymfony cd YOUR_PROJECT_NAME diff --git a/bin/nysymfony b/bin/nysymfony index 0139e6c..fc4609d 100755 --- a/bin/nysymfony +++ b/bin/nysymfony @@ -25,8 +25,6 @@ if [[ $COMPOSER -ne 0 ]]; then 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 ################################################################################ @@ -45,24 +43,18 @@ else echo "New symfony project called $1 created." fi +################################################################################ +# Symfony bin installed +################################################################################ + +git clone git@git.4lt.ca:nick/symfony.git nick + ################################################################################ # 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.4lt.ca/nick/symfony/raw/branch/master/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." +echo "Creating directories: sass" +mkdir -p sass ################################################################################ # SASS @@ -77,32 +69,58 @@ echo '.sass-cache' >> .gitignore echo '@import ../vendor/nickyeoman/sasslibrary/master.sass' > sass/project.sass echo "SASS installed you still need to run sass sass/$1.sass public/css/main.css" +################################################################################ +# 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 +cp vendor/nickyeoman/nytwig/symfony/twig.yaml config/packages/twig.yaml + +echo "Your twig.yaml config file has been replaced, remove the bak if you are happy." + ################################################################################ # Symfony bundles ################################################################################ -composer req nickyeoman/symfonycms +# https://symfony.com/doc/current/components/process.html (for running commands) +echo "Installing process" composer req symfony/process + +# https://symfony.com/doc/current/components/asset.html +echo "Installing asset" composer req asset -composer req symfony/mailer # gives prompt + +# https://symfony.com/doc/current/mailer.html +echo "Installing Mailer" +composer req -n symfony/mailer # gives prompt ################################################################################ # Symfony development bundles ################################################################################ -# Dev components -composer req --dev maker +# https://symfony.com/doc/current/profiler.html +echo "Installing profiler for dev" composer req --dev symfony/profiler-pack -composer req debug logger + +composer require cs-fixer-shim --dev + +# https://symfony.com/bundles/SymfonyMakerBundle/current/index.html +echo "Installing maker bundle for dev" +composer req --dev maker +sleep 2 +rm -rf vendor/symfony/maker-bundle/src/Resources/skeleton/controller/* +cp -R nick/maker/*.php vendor/symfony/maker-bundle/src/Resources/skeleton/controller/. ################################################################################ -# Symfony security +# Symfony form ################################################################################ -composer require symfony/security-bundle composer require form validator -composer require symfonycasts/verify-email-bundle -composer require symfonycasts/reset-password-bundle ################################################################################ # Database @@ -111,63 +129,11 @@ composer require symfonycasts/reset-password-bundle composer req -n orm --with-all-dependencies sleep 2 -################################################################################ -# Docker -################################################################################ - -# For the Apache container -composer req symfony/apache-pack #TODO: find a way to trigger this without interaction as it gives a prompt - -# 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 -ROOTPASS=`echo $RANDOM | md5sum | head -c 12` -echo "MYSQL_ROOT_PASSWORD=${ROOTPASS}" >> .env -echo 'DOCKERPHPMYADMIN=8001' >> .env -echo '' >> .env -echo '# Database info, should match your db url' >> .env -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 -echo '' >> .env -echo "DATABASE_URL=\"mysql://theuser${DBUSER}:${DBPASS}@${DBHOST}:3306/${DB}?serverVersion=mariadb-10.4.11&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 - -################################################################################ -# Routes -################################################################################ - -wget https://git.nickyeoman.com/nick/symfony/raw/branch/main/routes/routes.yaml -mv routes.yaml config/routes/symfonycms.yaml - -################################################################################ -# Clean up -################################################################################ - -composer update - ################################################################################ # Git ################################################################################ +rm -rf nick/ git add . git commit -m"New Project Script Run Completed" @@ -175,7 +141,7 @@ git commit -m"New Project Script Run Completed" # Instructions ################################################################################ -php bin/console --version +symfony console --version composer recipes diff --git a/maker/Controller.tpl.php b/maker/Controller.tpl.php new file mode 100644 index 0000000..3e97ddb --- /dev/null +++ b/maker/Controller.tpl.php @@ -0,0 +1,25 @@ + + +namespace ; + + + +class extends AbstractController +{ +generateRouteForControllerMethod($route_path, $route_name); ?> + public function (): ResponseJsonResponse + + { + + return $this->render('', [ + 'controller_name' => '', + 'debug' => null, + ]); + + return $this->json([ + 'message' => 'Welcome to your new controller!', + 'path' => '', + ]); + + } +} diff --git a/maker/twig_template.tpl.php b/maker/twig_template.tpl.php new file mode 100644 index 0000000..eac1901 --- /dev/null +++ b/maker/twig_template.tpl.php @@ -0,0 +1,13 @@ +{% extends '@nytwig/master.html.twig' %} + +{% block body %} +
+

Hello {{ controller_name }}! ✅

+ + This friendly message is coming from: + +
+{% endblock %} diff --git a/twig/twig.yaml b/twig/twig.yaml deleted file mode 100644 index e451aaf..0000000 --- a/twig/twig.yaml +++ /dev/null @@ -1,8 +0,0 @@ -twig: - default_path: '%kernel.project_dir%/templates' - paths: - '%kernel.project_dir%/vendor/nickyeoman/nytwig/src': 'nytwig' - -when@test: - twig: - strict_variables: true