File / Settings / Plugins / Browse remote
Symfony plugin : https://plugins.jetbrains.com/plugin/7219-symfony-plugin
PHP Annotations : https://plugins.jetbrains.com/plugin/7320-php-annotations
PHP Toolbox : https://plugins.jetbrains.com/plugin/8133-php-toolbox
Grafikart : YouTube
Les teachers du net : YouTube
https://symfonycasts.com/screencast/symfony
https://symfonycasts.com/screencast/symfony/setup
https://github.com/eewee/Symfony4
https://api.symfony.com/4.1/Symfony/Component/Routing/Generator/UrlGenerator.html
https://api.symfony.com/4.1/Symfony/Component/Serializer/Encoder/CsvEncoder.html
Liste bundle : flex.symfony.com (=https://symfony.sh/)
Demo/source Symfony 4 : demo
Subscriber : permet d'écouter les events de l'ORM preUpdate, postUpdate, preRemove, postRemove, ...
Projet web :
composer create-project symfony/website-skeleton my-project
Serveur web (option) :
composer require symfony/web-server-bundle --dev
Run serveur local sur http://127.0.0.1:8000/ :
php bin/console server:run
Checking for Security Vulnerabilities :
composer require sensiolabs/security-checker --dev
Apache - htaccess - Rewrite Rules (source) :
composer require symfony/apache-pack
Annotation :
composer require annotations
Check route :
php bin/console debug:router
SwiftMailer (source) :
composer require symfony/swiftmailer-bundle
https://symfony.com/doc/current/forms.html
composer require symfony/form
composer require symfony/validator
// Disable : HTML5 validator (required) :
{{ form_start(form, {'attr': {'novalidate': 'novalidate'}}) }}
Voir la req qui sera utilisée lors de la création du schéma de la db
php bin/console doctrine:schema:create --dump-sql
Créer le schéma de la db :
php bin/console doctrine:schema:create
Maj le schéma de la db :
php bin/console doctrine:schema:update
Autre :
php bin/console doctrine:migrations:status --show-versions
php bin/console doctrine:migrations:version YYYYMMDDHHMMSS --delete
ADD :
php bin/console doctrine:migrations:execute YYYYMMDDHHMMSS --up
DROP :
php bin/console doctrine:migrations:execute YYYYMMDDHHMMSS --down
CREATE MIGRATION :
php bin/console make:migration
EXEC MIGRATIONS :
php bin/console doctrine:migrations:migrate
Si on ajoute manuellement une valeur dans entity :
php bin/console make:entity --regenerate
Status :
php bin/console doctrine:migrations:status
Faire une requête :
php bin/console doctrine:query:sql "SELECT * FROM user"
Result :
array(1) {
[0]=>
array(3) {
["id"]=>
string(1) "1"
["username"]=>
string(6) "Thomas"
["password"]=>
string(60) "$2y$12$7kID8aQ/DOsY1Ue28SJV0OJwHXolrIsNce.Dhf/7dEt16gRH17ep6"
}
}
php bin/console doctrine:query:dql "SELECT u FROM App\Entity\User u"
array(1) {
[0]=>
object(stdClass)#597 (5) {
["__CLASS__"]=>
string(15) "App\Entity\User"
["id:App\Entity\User:private"]=>
int(1)
["username:App\Entity\User:private"]=>
string(6) "Thomas"
["password:App\Entity\User:private"]=>
string(60) "$2y$12$7kID8aQ/DOsY1Ue28SJV0OJwHXolrIsNce.Dhf/7dEt16gRH17ep6"
["text:App\Entity\User:private"]=>
array(0) {
}
}
Comprendre le OneToOne, OneToMany, ManyToOne et ManyToMany + Repository :
L'annotation ManyToOne a un attribut inversedBy.
L'annotation OneToMany a un attribut mappedBy.
Installer "Encore" pour la gestion des scss, css et js.
Lancer la commande “yarn encore dev --watch” durant le dev pour la compilation du scss.
Encore (assets > scss, css, js, …) :
https://symfony.com/doc/4.0/frontend/encore/installation.html
https://symfony.com/doc/current/frontend/encore/simple-example.html
Compile assets once : yarn encore dev
Or, recompile assets automatically when files change : yarn encore dev --watch
On deploy, create a production build : yarn encore production
Bootstrap CSS/JS :
https://symfony.com/doc/current/frontend/encore/bootstrap.html
https://symfony.com/doc/current/form/bootstrap4.html
Generate url (absolute / relative) :
https://symfony.com/doc/current/routing.html#routing-requirements (generateUrl)
https://symfony.com/doc/current/controller.html (redirectToRoute / redirect)
Template erreur 404, 500, etc … :
https://symfony.com/doc/current/controller/error_pages.html
Log :
https://symfony.com/doc/current/logging.html
https://symfony.com/doc/current/deployment.html
Tuto pour déployer avec Git :
https://fr.tuto.com/compte/achats/video/101881/player/#190751-preparation-du-depot-distant
OVH > https://geekco.fr/blog/deployer-un-site-symfony3-sur-ovh
https://thatelo.fr/blog/deployer-symfony-git-serveur
1/ git init :
cd /kunden/homepages/xx/dxxxxxxxxx/htdocs/var/git
mkdir sf4.git
cd sf4.git
git init --bare
2/ se placer dans le dossier hooks :
cd hooks
vi post-receive
3/ Edit post-receive ET coller ceci :
#!/bin/sh
git --work-tree=/kunden/homepages/xx/dxxxxxxxxx/htdocs/sf4_test/ --git-dir=/kunden/homepages/xx/dxxxxxxxxx/htdocs/var/git/sf4_test.git checkout -f
4/ Droit execution :
chmod +x post-receive
git init
git remote add live ssh://[email protected]/kunden/homepages/xx/dxxxxxxxxx/htdocs/var/git/sf4_test.git
git add .
git commit -m "Premier déploiement avec git"
git push live master
php composer.phar self-update
php composer.phar update
php composer.phar install --no-dev --optimize-autoloader
php bin/console cache:clear --env=prod --no-debug
php bin/console assets:install
// install composer
curl -sS https://getcomposer.org/installer | /usr/bin/php7.1-cli
// update composer
/usr/bin/php7.1-cli composer.phar self-update
// Heroku deploy :
https://afsy.fr/avent/2017/03-deployer-un-projet-symfony-flex-sur-heroku
SSH 1and1 :
Source : https://www.1and1.fr/digitalguide/serveur/securite/generer-des-cles-ssh-pour-votre-connexion-reseau/
http://thisisnotcnn.blogspot.com/2015/07/setup-remote-git-repository-on-1-server.html
http://flosy.info/2012/07/utilisation-de-git-avec-un-hebergement-de-1and1/
1/ Générer key :
cd .ssh
ssh-keygen -t rsa -C “[email protected]” -b 4096
/Users/xxx/.ssh/1and1_rsa
mdp (optionnel)
2/ Copier contenu 1and1_rsa.pub (local) dans ~/.ssh/authorized_keys (distant à la racine).
on peut le faire en uploadant 1and1_rsa.pub sur le serveur.
cat id_rsa.pub >> ~.ssh\authorized_keys
3/ En local :
cd ~/.ssh
ssh-add 1and1_rsa
4/ En distant :
On copie la key public dans .ssh/authorized_keys (à la racine du FTP 1and1) :
cat ~/id_rsa_1and1.pub >> ~/.ssh/authorized_keys
5/ test en indiquant :
ssh [email protected] ls
On doit avoir le rendu sans devoir indiquer le mot de passe ssh.
git clone ssh://[email protected]/kunden/homepages/xx/dxxxxxxxxx/htdocs/var/git/sf4_test.git
git pull ssh://[email protected]/kunden/homepages/xx/dxxxxxxxxx/htdocs/var/git/sf4_test.git master