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