web:php:chap7

Chapitre 7 : Notion de Framework PHP

Framework = cadriciel

Ensemble de conposants logiciels fournissant un cadre de conception

Quelques frameworks connus :

CodeIgniter, Symfony, Laravel, Phalcon, Cake PHP, Zend, Yii

Les frameworks permettent d'intégrer facilement certains concepts ou fonctionnalités dans une application :

MVC est un patron de conception (design pattern) permettant de séparer les différentes composantes d'une application suivant leur rôle :

  • M = Modèle (logique et classes métier)
  • V = Vue (Partie présentation, interface utilisateur)
  • C = Contrôleur (Logique applicative, contrôle, synchronisation)

  • Rôle d'affichage uniquement, reçoivent les données du contrôleur
  • Utilisation de moteur de template (cache)

<table class='table table-striped'>
	<thead><tr><th colspan='3'>{{model}}</th></tr></thead>
		<tbody>
		{% for object in objects %}
			<tr>
			<td>{{object.toString()|raw}}</td>
			<td class='td-center'><a class='btn btn-primary btn-xs' href='{{baseHref~"/frm/"~object.getId()}}'>...</a></td>
			<td class='td-center'><a class='btn btn-warning btn-xs' href='{{baseHref~"/delete/"~object.getId()}}'>X</a></td>
			</tr>
		{% endfor %}
		</tbody>
</table>
<a class='btn btn-primary' href='{{config["siteUrl"]~baseHref~"/frm"}}'>Ajouter...</a>

  • Généré en PHP
  • Dans les contrôleurs, puis insérés dans la vue

	public function index() {
		$this->loadView("main/vHeader.html",array("infoUser"=>Auth::getInfoUser()));
		$this->loadView("main/vDefault.html");
		$this->loadView("main/vFooter.html");
		Jquery::getOn("click", ".btAjax", "Sample/ajaxSample","#response");
		echo Jquery::compile();
	}

  • web/php/chap7.txt
  • Dernière modification : il y a 6 mois
  • de jcheron