Contenu connexe Similaire à The state of Symfony2 - SymfonyDay 2010 (20) Plus de Fabien Potencier (17) The state of Symfony2 - SymfonyDay 20103. How many of you have already
played with Symfony2?
http://www.flickr.com/photos/bartworldv6/4206815555
4. Symfony2 is not ready for production
http://www.flickr.com/photos/rknickme/2205111920
6. Crazy people
do use Symfony2
http://www.flickr.com/photos/funky64/4267353106/
12. symfony vs Symfony2
http://www.flickr.com/photos/thebusybrain/2492945625
24. [-Inf,0[ WTF?!|
{0} No apples|
{1} One apple|
[2,19] Some apples|
[20,Inf] Many apples
27. PHP vs Twig
http://www.flickr.com/photos/danielmarenco/4775410299
39. {% transchoice 1 from app %}
No apples|One apple|{{ count }} apples
{% endtranschoice %}
42. Customizing
Forms
http://www.flickr.com/photos/blackbutterfly/2304084815
43. {{ form|render_enctype }}
{{ form|render_errors }}
{{ form|render_hidden }}
{{ form.name|render_widget }}
{{ form.name|render_label }}
{{ form.name|render_errors }}
{{ form.name|render_data }}
46. {% block input_field %}
{% tag "input" with attributes %}
{% endblock %}
{% block textarea_field %}
{% contenttag "textarea" with attributes %}
{{ field.displayedData }}
{% endcontenttag %}
{% endblock %}
49. How can I customize the rendering of
the widget?
51. {% block input_field %}
<span class="input_field">
{% tag "input" with attributes %}
</span>
{% endblock %}
53. How can I customize the rendering of
all input widgets for a given form?
55. How can I customize the rendering of
all input widgets for all forms?
56. <twig:config>
<twig:form>
<twig:resource>
BlogBundle::widgets.twig
</twig:resource>
</twig:form>
</twig:config>
59. {% block input_field %}
<span class="input_field">
{% parent %}
</span>
{% endblock %}
{% block textarea_field %}
<span class="textarea_field">
{% parent %}
</span>
{% endblock %}
...
60. {% block input_field %}
{% tag "input" with attributes %}
{% endblock input_field %}
{% block textarea_field %}
{% contenttag "textarea" with attributes %}{{ field.displayedData }}{% endcontenttag %}
{% endblock textarea_field %}
{% block choice_field %}
{% if field.options.expanded %}
{% for child in field %}{{ child|render_widget }}{% endfor %}
{% else %}
{% contenttag "select" with attributes %}{{ field|render_choices }}{% endcontenttag %}
{% endif %}
{% endblock choice_field %}
{% block toggle_field %}
{% display input_field %}
{% if field.options.label %}{% contenttag "label" with ['for': field.id] %}{% trans field.options.label %}{% endcontenttag %}{% endif %}
{% endblock toggle_field %}
{% block date_time_field %}
{{ field.date|render_widget }}{{ field.time|render_widget }}
{% endblock date_time_field %}
{% block date_field %}
{% if field.field %}
{% display input_field %}
{% else %}
{{ field.pattern|replace(['{{ year }}': field.year|render_widget, '{{ month }}': field.month|render_widget, '{{ day }}': field.day|
render_widget,]) }}
{% endif %}
{% endblock date_field %}
{% block time_field %}
{% if field.isfield %}
{% display input_field %}
{% else %}
{{ field.hour|render_widget }}:{{ field.minute|render_widget }}
{% if field.options.with_seconds %}:{{ field.second|render_widget }}{% endif %}
{% endif %}
{% endblock time_field %}
{% block money_field %}
{% set widget %}{% display input_field %}{% endset %}{{ field.pattern|replace(['{{ widget }}': widget]) }}
{% endblock money_field %}
{% block percent_field %}
{% display input_field %} %
{% endblock percent_field %}
64. symfony Core sf*GuardPlugin Your Code
$this->getUser()->getGuardUser()->getProfile()
72. <provider>
<class="AccountBundleModelUser" />
</provider>
74. <provider>
<entity class="AccountBundle:User" />
</provider>
76. <provider>
<entity class="AccountBundle:User" property="user" />
</provider>
77. What if I want to use the email for the username?
79. But, I just have one administrator
or… How can I secure my personal website backend?
80. <provider>
<user name="fabien" password="C00!" role="ROLE_ADMIN" />
</provider>
81. <provider>
<password-encoder hash="sha1" />
<user name="fabien"
password="0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33"
role="ROLE_ADMIN" />
</provider>
84. What if I want to use LDAP, in-memory, and a DB for my users?
85. <provider>
<password-encoder hash="sha1" />
<user name="fabien" password="..." role="ROLE_ADMIN" />
</provider>
<provider>
<entity class="AccountBundle:User" property="user" />
</provider>
87. Request
core.request
getController()
core.controller
core.exception
getArguments()
core.view
core.response
Response
89. Request
core.request
core.security HttpKernelSecurityFirewall
getController()
core.controller
getArguments()
core.view
core.response
Response
94. What if I want different authentication strategies in one app?
98. What if I want to support
different authentication strategies
in one section of an app?
99. <firewall>
<form-login />
<http-basic />
</firewall>
101. Authorization
http://www.flickr.com/photos/theodevil/4911737917
102. <access>
<url path="/api/.*" role="ROLE_REMOTE" />
</access>
103. <access>
<url role="ROLE_USER">
<attribute key="_controller"
pattern=".*BlogBundle.*" />
</url>
</access>
104. /article/:id
<access>
<url role="ROLE_ADMIN">
<attribute key="id" pattern="21" />
</url>
</access>
<access>
<url path="/article/21" role="ROLE_ADMIN" />
</access>
106. <access>
<url path="/api/.*" role="ROLE_REMOTE" />
<url path="/public/.*"
role="IS_AUTHENTICATED_ANONYMOUSLY" />
<url role='ROLE_USER'>
<attribute key="controller"
pattern=".*BlogBundle.*" />
</url>
</access>
110. Symfony2: The Web Operating System?
Kernel
Events
Proxy
Firewall
Bundles
http://www.flickr.com/photos/declanjewell/2687934284