Silex Code Fiddles/Examples

silex

For the course Webscripting2 I’m lecturing at ikdoeict.be/KaHo Sint-Lieven, we’re working with Silex. Next to the slidedeck explaining Silex, all examples are freely available on GitHub (links at the bottom of this post)

The collection of examples start with the very basics of Silex and introduce more routing options and services as they continue.

  1. Basic:
    The basic Silex app structure.
  2. Hello:
    The infamous Hello world showcasing the basic Silex app structure, dynamic routing, redirects, and error handlers.
  3. Olleh:
    More routing showcasing requirements, default values, and Route Variable Converters.
  4. Tweets:
    Practical example demonstrating routes using some (static) data.
  5. Tweets Organized:
    Organizes the controllers for the different routes in classes; it’s all about the structure!
  6. Tweets Twig:
    Introduces the built-in TwigServiceProvider, allowing one to use Twig within a Silex app.
  7. Doctrine:
    Introduces the built-in DoctrineServiceProvider, allowing one to use Doctrine’s DBAL within a Silex app.
  8. Doctrine Organized:
    Organizes our codebase a tad better: per entity we introduce a repository which acts as a database layer. Depends on the custom Service Provider knplabs/repository-service-provider (loaded via Composer).
  9. Static Pages:
    Introduces named routes, the UrlGeneratorServiceProvider and a neat little trick to quickly add a few static pages to a project
  10. Middlewares:
    Introduces Middlewares and along with that the MonologServiceProvider
  11. Forms & Validation:
    Introduces the FormServiceProvider and ValidatorServiceProvider

More examples are still in development. The examples are best studied along with the accompanying slides.

Webscripting2 – Serverside Scripting – Silex Code Fiddles →
Webscripting2 – Serverside Scripting – Course Materials →

Note: the course materials are best cloned locally. The fiddles are also included in that repository. Be sure to composer install all examples.

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.