+ All Categories
Home > Internet > The symfony components

The symfony components

Date post: 15-Apr-2017
Category:
Upload: alexandra-negrea
View: 360 times
Download: 1 times
Share this document with a friend
24
Using the Symfony components
Transcript
Page 1: The symfony components

Using the Symfony components

Page 2: The symfony components

◦ Decoupled◦ Reusable◦ Independent◦ Maintained◦ PHP libraries

Components

Page 3: The symfony 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

Page 4: The symfony components

◦ Package manager for PHP applications.◦ Makes it easy to reuse code (on a per

project basis).

Composer

Page 5: The symfony components

Developing a PHP application from scratch

Page 6: The symfony components

Place your screenshot here

Spaghetti Code -

Never a good idea!

◦ not scalable◦ big, scary

bugs can hide in plain sight

Page 7: The symfony components

Http FoundationThe HttpFoundation component defines an object-oriented layer for the HTTP specification.

Page 8: The symfony components

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

Page 9: The symfony components

DebugEases the debugging of code, providing handlers for errors and exceptions and even suggestions for classes that could not be loaded.

Page 10: The symfony components

RoutingMaps an HTTP request to a set of configuration variables.

Page 11: The symfony components

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

Page 12: The symfony components

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.

Page 13: The symfony components

FormThe Form component allows you to easily create, process and reuse HTML forms.

Page 14: The symfony components

ValidatorBased on the JSR-303 Bean Validation specification.

Enables specifying validation rules for classes using XML, YAML, PHP or annotations.

Page 15: The symfony components

SerializerThe Serializer component is meant to be used to turn objects into a specific format (XML, JSON, YAML, ...) and the other way around.

Page 16: The symfony components

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

Page 17: The symfony components

HOW DOES IT WORK?

Page 18: The symfony components

TemplatingThe Templating component provides all the tools needed to build any kind of template system.

Page 19: The symfony components

The Templating Component

Provides:

◦ Template files loading and tracking◦ Template engine implementation using

PHP◦ Output escaping ◦ Separation of templates into blocks and

layouts

Page 20: The symfony components

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.

Page 21: The symfony components

Event DispatcherThe EventDispatcher component provides tools that allow your application components to communicate with each other by dispatching events and listening to them.

Page 23: The symfony components

Http KernelThe HttpKernel component provides a structured process for converting a Request into a Response by making use of the EventDispatcher component.

Page 24: The symfony components

Thanks!

ANY QUESTIONS?You can find me at

[email protected]


Recommended