/pscSilex

Code for the phpSummerCamp Silex workshop.

phpSummerCamp Silex Workshop

With some very simple examples, during 1h30, you will discover how to :

  • Run Silex locally with Vagrant / Docker / phusion
  • Run Silex with php-fpm + nginx
  • Build a simple navigation system from a YAML content tree, Twig for templating & bootstrap for CSS
  • Use Pimple to inject the YAML content within the $app container, and re-use everywhere
  • Provide 3 ways to embed external HTML blocks : SSI / ESI / AJAX, with HTTP Cache TTL (use HttpFoundation)
  • Create a generic service provider to compile locally the bootstrap .less files with cache / watch changes / compress (use less.php)

Branch topics :

  • Branch master is empty
  • Branch 01-no-esi is the starting point of the workshop. The AJAX call is in progress (/renderesi route is missing), no ESI setup, no .less compilation
  • Branch 02-no-less is the same code, containing AJAX & ESI setup example
  • Branch 03-final is the final code, containing the .less processing for bootstrap

How to run the workshop

From the Vagrant/Docker

Check Vagrant & Docker are installed & so :

vagrant up --provider=docker

If you are behind a proxy, uncomment & set your proxy values in the Vagrantfile & Dockerfile

From the SummerCamp VBox

With SSH go to the Silex folder :

ezsc@ezsc:/var/www/html/workshops/silex$

You should already be on the 01-no-esi branch, with all vendors available, Up to branch 02-no-less, need to :

composer update oyejorge/less.php

Exercises

From 01-no-esi

  • Finalize the AJAX call, add "/renderesi" route to controllers.php
  • Add "/esi" route to controllers.php, with TTL cache
  • Add entry to the menu.yaml
  • Add template code to the main.twig

To speed up, checkout the 02-no-less branch

From 02-no-less

  • Add "oyejorge/less.php": "~1.5" to composer.json & update
  • Create the LessProvider, both register & boot methods
  • Register the provider in app.php
  • Play with variables.less to check everything works fine

To speed up, checkout the 03-final branch

Enjoy !