Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

SYMFONY 3.4.8 :

Creer un nouveau projet dans le dossier sf348

composer create-project symfony/skeleton sf348

Lancer un serveur :

php -S 127.0.0.1:8000 -t public

ou

composer require server

bin/console server:run

Ouvrir le serveur (browser)

http://localhost:8000/

VRAC :

AutoWiring

  • php bin/console debug:autowiring

Annotations (pour les roots en commentaire)

  • composer require annotations

Barre de debug

  • composer require profiler --dev

Add "encore" > add webpack.config.js

  • composer require encore

Asset support (ex : for add css/js)

  • composer require asset

Security :

  • composer require sec-checker
  • php bin/console security:check
  • packagist

Package

PHPStorm

Form :

composer require form

Validator (@Assert)

composer require validator

Source

Required field form

NEW BROWSER > Class ProductType (for remove the default 'required'):

->add('price', NumberType::class, array('required' => false))

OLD BROWSER > class Product (entity) :

(You can use NotBlank or NotNull)

@Assert\NotBlank

@ORM\Column(type="decimal", scale=2, nullable=true)

private $price;

RECIPE :

FAKER

tuto : https://blog.dev-web.io/

MAKE :

Pour créer un CRUD

composer require security-csrf php bin/console make:crud User

Pour la génération de code

composer require maker-bundle

Pour créer une controller

php bin/console make:controller Posts

Pour créer un form

php bin/console make:form Post

Entite Post

php bin/console make:entity Post

DB (ORM / Doctrine):

ORM

composer require orm

Doctrine

composer require doctrine maker

Config .env

  • db_user
  • db_password
  • db_host
  • db_name

create db

php bin/console doctrine:database:create

create entity class

php bin/console make:entity Product

Génère le sql à utiliser pour la migration (db)

php bin/console doctrine:migrations:diff ou php bin/console doctrine:schema:update --dump-sql

Lance la migration

php bin/console doctrine:migrations:migrate ou php bin/console doctrine:schema:update --force

Rendu Sql (for the fun)

php bin/console doctrine:query:sql 'SELECT * FROM product'

Propriétaire / Inverse

Propriétaire : celui qui stockera xxx_id (ex : address_id) https://openclassrooms.com/courses/developpez-votre-site-web-avec-le-framework-symfony2/les-relations-entre-entites-avec-doctrine2#/id/r-2086605

PAGINATION :

KNP Paginator

TWIG :

Doc : https://twig.symfony.com/doc/2.x/

Theme

http://symfony.com/doc/current/form/form_customization.html

/config/packages/twig.yaml :

twig:

form_themes: ['bootstrap_4_horizontal_layout.html.twig']

DEBUG :

  • Php (in controller) : dump($your_var, $this, $other);
  • Twig : {{ dump() }}
  • composer require profiler --dev
  • composer require debug

TEST UNIT :

COMMAND :

  • php bin/console debug:router
  • php bin/console cache:clear

About

:octocat: Test symfony 3.4.8.

Resources

License

Releases

No releases published

Packages

No packages published