modify maker
This commit is contained in:
parent
c2080db9a4
commit
3789f05ef4
@ -12,7 +12,7 @@ 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 4lt.ca/nysymfony
|
||||||
bash nysymfony YOUR_PROJECT_NAME
|
bash nysymfony YOUR_PROJECT_NAME
|
||||||
rm nysymfony
|
rm nysymfony
|
||||||
cd YOUR_PROJECT_NAME
|
cd YOUR_PROJECT_NAME
|
||||||
|
124
bin/nysymfony
124
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 'Checkout how to Install Composer here: https://www.nickyeoman.com/blog/php/install-composer-on-ubuntu/'
|
||||||
echo 'Once installed, try running this script again'
|
echo 'Once installed, try running this script again'
|
||||||
exit 1
|
exit 1
|
||||||
else
|
|
||||||
echo "Composer is installed and ready to go."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -45,24 +43,18 @@ else
|
|||||||
echo "New symfony project called $1 created."
|
echo "New symfony project called $1 created."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Symfony bin installed
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
git clone git@git.4lt.ca:nick/symfony.git nick
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Create directories
|
# Create directories
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
echo "Creating directories: sass, scripts"
|
echo "Creating directories: sass"
|
||||||
mkdir -p sass scripts
|
mkdir -p sass
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# 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."
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# SASS
|
# SASS
|
||||||
@ -77,32 +69,58 @@ echo '.sass-cache' >> .gitignore
|
|||||||
echo '@import ../vendor/nickyeoman/sasslibrary/master.sass' > sass/project.sass
|
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"
|
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
|
# Symfony bundles
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
composer req nickyeoman/symfonycms
|
# https://symfony.com/doc/current/components/process.html (for running commands)
|
||||||
|
echo "Installing process"
|
||||||
composer req symfony/process
|
composer req symfony/process
|
||||||
|
|
||||||
|
# https://symfony.com/doc/current/components/asset.html
|
||||||
|
echo "Installing asset"
|
||||||
composer req 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
|
# Symfony development bundles
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Dev components
|
# https://symfony.com/doc/current/profiler.html
|
||||||
composer req --dev maker
|
echo "Installing profiler for dev"
|
||||||
composer req --dev symfony/profiler-pack
|
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 form validator
|
||||||
composer require symfonycasts/verify-email-bundle
|
|
||||||
composer require symfonycasts/reset-password-bundle
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Database
|
# Database
|
||||||
@ -111,63 +129,11 @@ composer require symfonycasts/reset-password-bundle
|
|||||||
composer req -n orm --with-all-dependencies
|
composer req -n orm --with-all-dependencies
|
||||||
sleep 2
|
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
|
# Git
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
rm -rf nick/
|
||||||
git add .
|
git add .
|
||||||
git commit -m"New Project Script Run Completed"
|
git commit -m"New Project Script Run Completed"
|
||||||
|
|
||||||
@ -175,7 +141,7 @@ git commit -m"New Project Script Run Completed"
|
|||||||
# Instructions
|
# Instructions
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
php bin/console --version
|
symfony console --version
|
||||||
|
|
||||||
composer recipes
|
composer recipes
|
||||||
|
|
||||||
|
25
maker/Controller.tpl.php
Normal file
25
maker/Controller.tpl.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?= "<?php\n" ?>
|
||||||
|
|
||||||
|
namespace <?= $namespace; ?>;
|
||||||
|
|
||||||
|
<?= $use_statements; ?>
|
||||||
|
|
||||||
|
class <?= $class_name; ?> extends AbstractController
|
||||||
|
{
|
||||||
|
<?= $generator->generateRouteForControllerMethod($route_path, $route_name); ?>
|
||||||
|
public function <?= $method_name ?>(): <?php if ($with_template) { ?>Response<?php } else { ?>JsonResponse<?php } ?>
|
||||||
|
|
||||||
|
{
|
||||||
|
<?php if ($with_template) { ?>
|
||||||
|
return $this->render('<?= $template_name ?>', [
|
||||||
|
'controller_name' => '<?= $class_name ?>',
|
||||||
|
'debug' => null,
|
||||||
|
]);
|
||||||
|
<?php } else { ?>
|
||||||
|
return $this->json([
|
||||||
|
'message' => 'Welcome to your new controller!',
|
||||||
|
'path' => '<?= $relative_path; ?>',
|
||||||
|
]);
|
||||||
|
<?php } ?>
|
||||||
|
}
|
||||||
|
}
|
13
maker/twig_template.tpl.php
Normal file
13
maker/twig_template.tpl.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{% extends '@nytwig/master.html.twig' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<div class="example-wrapper">
|
||||||
|
<h1>Hello {{ controller_name }}! ✅</h1>
|
||||||
|
|
||||||
|
This friendly message is coming from:
|
||||||
|
<ul>
|
||||||
|
<li>Your controller at <code><?= $root_directory ?>/<?= $controller_path ?></code></li>
|
||||||
|
<li>Your template at <code><?= $root_directory ?>/<?= $relative_path ?></code></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
@ -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
|
|
Reference in New Issue
Block a user