Speaker: Dustin Whittle
Slides: https://speakerdeck.com/u/dustinwhittle/p/silex-from-micro-to-full-stack
What is silex?
- Micro framework based on Symfony components
- Requires 5.3.3+
Limitations
- No cli tool
- Any feature that requires mandatory external files
- TODO: grab others
Why Use?
- TODO: too fast
- Single app structure
- One front controller with routing functions
- composer enabled
- Bootstrap skeletons available
- fabbot/silex-skeleton
- just use it.
- has symfony exception handling
- fabbot/silex-skeleton
- Holy crap, Dustin is coding on the fly. Repo to follow.
- Uses Pimple for a DIC
- Similar to bundles for Symfony
Core providers
- URL gen
- Session
- validator
- TODO: more listed
- Register twig
- Set Path
- Register trans
- set dictionary
- access
$app->translator
- register form service provider
- create form
- uses a form factory service
- form builder
- add form fields
- bind request to form
- return form w/view
- register validator
- register translator
- specify validation constraints
- assert constraints
- proceed as sf2
- register httpcache
- set cache dir
- return response object w/cache headers
Caveat: NOT the orm, if you need it, use SF2
- exposes a PDO object
- register doctrine provider
- set driver
- set path
- execute query
- Silex "sweet spot"
- if you need a simple JSON API, "use silex"
- Already has doctrine set up, just return JSON encoded data
- uses routes and request objects to mutate the query
- register monolog
- set logfile
- write to log
- register swiftmailer
- set swift message
- send message
CAVEAT: if you need security, you should be using SF2
- register security provider
- add firewall
- set patterns
- set routes
- fetch token
- default structure
- default conventions
- configuration (yml, xml, ini, etc)
- sf2 you remove features
- silex you add them
- exposing new functionality w/service providers
- moving out of a single file
- controllers in diff files
- template files
CAVEAT: goal is to be lightweight.
- assetic
- memcache
- mongodb
- redis
- markdown
https://github.com/fate/Silex-Extensions
- integrate any third party library easily by adding a service to the container
- facebook SDK
$app->share
returns service to the container
- SF2
- Compiler
- XML/YAML
- Loader
- Extension
- Builder
- App
- Silex
- Service Container
- App
https://github.com/lyrixx/Silex-Kitchen-Edition
- H5BP + Twitter Bootstrap
- Providers and examples
- Twig, cache, security, blah blah blah too fast
Silex Backbone
- Too fast.
Fabpot skeleton already has twig/silex helpers already registered
Seems that Dustin has started with a stock Silex install. Through using composer and fabpot's skeleton, he's slowly building up Silex to be more full featured, and utilizes more of Symfony's underlying core. So far, controller functions have been broken out into another file rather than in the front matter. Exceptions have been brought over from Symfony as well.