You are on page 1of 2

bech truni l projet hell terminal fell directory mtaa projet

symfony server:start walla symfony serve

--------- Integration template


Telecharger l template
tsob les fichiers css js w img mtaa l template sous dossier public fell projet
mteek
w tjib l homepage (code html mteeha ) mtaa ltemplate li telechargitha thotha fell
base.html.twig
mbaaed ay hajja kima l format hedhi
<link href="assets/vendor/simple-datatables/style.css" rel="stylesheet">
<link href="assets/vendor/remixicon/remixicon.css" rel="stylesheet">
tbadalha trodha hakka (5ater les lien kima haka ma yakrahomch
assets/vendor/remixicon/remixicon.css yelzem tkolou win enti hatithom w nahna
hatinehom taht l /public w bech y'accedi l /public b hedhi {{asset('vendor/simple-
datatables/style.css')}} donc twali temchi
<link href="{{asset('vendor/simple-datatables/style.css')}}" rel="stylesheet">
<link href="{{asset('vendor/remixicon/remixicon.css')}}" rel="stylesheet">
kifkif bennesba lel javascript

<script src="assets/vendor/tinymce/tinymce.min.js"></script>
<script src="assets/vendor/php-email-form/validate.js"></script>
trodou hakka
<script src="{{asset('vendor/tinymce/tinymce.min.js')}}"></script>
<script src="{{asset('vendor/php-email-form/validate.js')}}"></script>
w tzid {% block body %}
{% endblock %}
hedha lkoll bech taamlou martin khater aandek 2 templates wahda front office mtaa l
user w wahda backoffice mtaa ltemplate
- lback office heya /templates/base.html.twig
- lfront office heya /templates/frontTemplate.html.twig

--------- Generation des entités


fell .env tbadel esm l base de données kima li aandek fell mysql kima fell ligne
hedha
1)DATABASE_URL="mysql://root:@127.0.0.1:3306/job4you?serverVersion=8"

2) php bin/console doctrine:mapping:import "App\Entity" annotation


--path=src/Entity
3) php bin/console make:entity --regenerate App
4) php bin/console make:crud w tekteb esm l entite li bech yaamlemha crud
( yasnaalek mathalan UserController sous src/controller w dossier esmou user
sous /templates
talka fih _form , edit,index,show,new _delete .html.twig )

-----Controle de saisie
temchi lel entité eli bech taamel feha controle de saisie thot l ligne hedhi
melowel
use Symfony\Component\Validator\Constraints as Assert;

mbaaed tzid les controle de saisie fouk koll attribut thheb taamel aalih kima l
example hedha

/**
* @var string
*
* @ORM\Column(name="message_rep", type="string", length=255)
*/
private $messageRep;

badalneh radina
/**
* @var string
*
* @ORM\Column(name="message_rep", type="string", length=255)
* @Assert\NotBlank
* @Assert\Length(
* min = 5,
* max = 50,
* minMessage = "Your message must be at least {{ limit }} characters
long",
* maxMessage = "Your message cannot be longer than {{ limit }}
characters"
* )
*/
private $messageRep;
mbaaed temchi /teamplates/esm l entite / _form.html.twig
thhot l ligne hedhi
{{form_start(form,{'attr':{'class':'form-
horizontal',novalidate:'novalidate'}})}} // novalidate:'novalidate' hedheya lezma
bech ywwali yaamel les controle de saisie
fi blaset hedhi ( li par defaut )
{{ form_start(form) }}

w thhot hedhom
<tr>
<td>{{form_label(form.message,"Message")}}</td> ( hedhi l
message li bjnab l input ) form.message edheka esm l attribut w l "Message" chnowa
bch ikounn affiché
<td>{{form_widget(form.message,{ 'attr': {'class': 'form-control my-2'} })}}</td>
(hedhi l input bidou ) w hedhi { 'attr': {'class': 'form-control my-2'} } juste
zina bech twali l input adheka tzidou class css form-control li heya tzayen w kahaw
<td>{{form_errors(form.message)}}</td> // bech y'affichi l
message d'erreur ghadi
</tr>

You might also like