Upload
alexandra-negrea
View
377
Download
1
Embed Size (px)
Citation preview
Using the Symfony components
◦ Decoupled◦ Reusable◦ Independent◦ Maintained◦ PHP libraries
Components
Installable via Composer
31 Reusable Components
AssetBrowserKit
ClassLoader
Config
console
CssSelector
DependencyInjection
debug
finderDomCrawler
ExpressionLanguage
LocaleHttpFoundation
VarDumper
Process
ICU
EventDispatcher
FileSystem
INTL
Routing
PropertyAccessor
Security
form
Serializer
Templating
OptionsResolver
Translation Validator YAML
◦ Package manager for PHP applications.◦ Makes it easy to reuse code (on a per
project basis).
Composer
Developing a PHP application from scratch
Place your screenshot here
Spaghetti Code -
Never a good idea!
◦ not scalable◦ big, scary
bugs can hide in plain sight
Http FoundationThe HttpFoundation component defines an object-oriented layer for the HTTP specification.
Http Foundation
◦ Wraps around an OOP approach the global HTTP variables ($_SESSION, $_COOKIE, $_GET, $_POST, $_FILES);
◦ Help manage Request, Response, Cache, Cookies, Session, Streaming and Serving Files
◦ Provides Session mocking capabilities for testing
DebugEases the debugging of code, providing handlers for errors and exceptions and even suggestions for classes that could not be loaded.
RoutingMaps an HTTP request to a set of configuration variables.
The routing component
◦ Define routes◦ Add prefixes and suffixes to routes◦ Set request parameters◦ Allow the parameters default values◦ Generate URLs◦ Load routes from a file (xml, yml, php
format), a Closure, annotations◦ Match URIs◦ Cache routes◦ Use service parameters in routes
You can use parameters in your route:
mobile_homepage:path: /%my.parameter%host: “m.{domain}”defaults:
_controller: AcmeDemoBundle:Main:mobileHomepagedomain: “%domain%”
What if I have a % in my route?
mobile_homepage:path: /%%%my.parameter%host: “m.{domain}”defaults:
_controller: AcmeDemoBundle:Main:mobileHomepagedomain: “%domain%”
No problem! % characters need to be escaped by one % character.
FormThe Form component allows you to easily create, process and reuse HTML forms.
ValidatorBased on the JSR-303 Bean Validation specification.
Enables specifying validation rules for classes using XML, YAML, PHP or annotations.
SerializerThe Serializer component is meant to be used to turn objects into a specific format (XML, JSON, YAML, ...) and the other way around.
The serializer Component
You can:
◦ Serialize/deserialize an existing object◦ Use serialization groups (~2.7)◦ Convert property names when
serializing/deserializing◦ Use camelCase or snake_case◦ Handle circular references
HOW DOES IT WORK?
TemplatingThe Templating component provides all the tools needed to build any kind of template system.
The Templating Component
Provides:
◦ Template files loading and tracking◦ Template engine implementation using
PHP◦ Output escaping ◦ Separation of templates into blocks and
layouts
Dependency InjectionThe DependencyInjection component allows you to standardize and centralize the way objects are constructed in your application.
Reinforces inversion of control from the SOLID principles.
Event DispatcherThe EventDispatcher component provides tools that allow your application components to communicate with each other by dispatching events and listening to them.
SecurityProvides a complete security system for your web application.
Http KernelThe HttpKernel component provides a structured process for converting a Request into a Response by making use of the EventDispatcher component.