0
Dustin Whittle - dustin@yahoo-inc.com
Who am I?
Yahoo! – Application Platform + Dev Network
 Worked with Y! Answers, Delicious, Y!
 Bookmarks, Y! Widgets, Yahoo...
symfony-project.com | developer.yahoo.com/yui
Users

                         Load Balancers

                              Frontend

    Apache                        ...
Why use a frontend
        platform?
Rasmus says “frameworks are not well suited for Y!”
  Build applications to requireme...
Why use a framework?
Another software layer (ysymfony, yphp, yapache)

Factors out common patterns

   Code Layout, Configu...
YUI3

The syntax is more terse, allowing you to write
more compact code using techniques like
chaining.
The API is selecto...
YUI3
Lighter

   Don't load what you don't need

   Don't write code more than once, use it again

Easier

   Consistent A...
What is symfony?

A full stack MVC Framework
Written in OOP PHP5
Developed by a French company, Sensio Labs
Released open ...
The Big Picture
A complete platform for building web applications
from frameworks
  PHP Framework
  JavaScript Framework
 ...
Open Source
Communities
Who uses ysymfony/yui?
symfony is a cohesive and
  decoupled set of PHP
         classes
symfony Platform
The symfony framework is
  based on the symfony
        platform
symfony Framework
Model-View-Controller
Some people think
frameworks are slow and
    trap you in a box.
Performance?
symfony in features
MVC Design + Project/Application Structure

Cascading Configuration System (YAML -> PHP)

Environments ...
Symfony vs ?


Make your choice based on the requirements of
the project
 Pick a framework or just a component
Getting Started
pear channel-discover pear.symfony-project.org
pear install symfony/symfony


mkdir ~/dev/ysfproject;
cd ~...
symfony CLI + Tasks
sfEventDispatcher
// sfPatternRouting
$callback = array($this, ’filterParameters‘);
$dispatcher->connect(’request.filter_par...
application.log

application.throw_exception

context.load_factories

request.filter_parameters

user.change_culture

contr...
require '/home/y/share/pear/symfony/autoload/
sfCoreAutoload.class.php';
sfCoreAutoload::register();


$dispatcher = new s...
symfony Configuration
Based on YAML

Support for environments

   prod, dev, test, qa, staging, ...

Dimension System

   A...
homepage:
 url: /
 param: { module: common, action: homepage }

item_get:
  url: /api/v1/item/:id
  param: { module: item,...
frontend/modules/common/actions/actions.class.php

class commonActions extends sfActions
{
  public function executeHomepa...
symfony view layer
Actions can render different views, a partial, or a
component

  (think: same controller for ajax/full ...
class SigninForm extends sfForm
{
  public function configure()
  {
    $this->setWidgets(array(
      'username' => new sf...
<form action=“<?php echo url_for(‘user/signin’);”
method=“post”>
<?php echo $form; ?>
</form>
$this->form = new SigninForm();

if ($request->isMethod('post'))
{
  $this->form->bind($request->getParameter('user'));
  ...
symfony / YUI
YUI integration is provided in the form of template
helpers
  AJAX
  Buttons
  Tabs
  Overlays
Debug Toolbar...
Debugging Tools
Deployment Tools

Aggregate and minify stylesheets and javascripts

Rewrite templates, css, js for CDN (YCS)

Generate tra...
LIME Unit Testing




   ./symfony test:unit
$t = new lime_test(9, new lime_output_color());

// create configuration
$t->comment('check configuration');
$frontendConfigu...
LIME Functional Testing



  ./symfony test:functional backend
$browser = new frontendTestFunctional(new sfBrowser());
$browser->get('/')->

 with('view_cache')->begin()->
  isCached(fa...
YUI Unit Testing
YUI({combine: true, timeout: 10000}).use("node", "console", "test",function (Y) {
 Y.namespace("example.test");
 Y.example...
symfony Documentation
http://www.symfony-project.org/doc/
 Practical symfony - Jobeet
 The Definitive Guide to symfony
 The...
http://www.symfony-project.org/jobeet/
                          1_2/

A set of 24 tutorials
Each tutorial is
meant to las...
Support
Forums

   http://www.symfony-project.com/forum

IRC

   irc.corp.yahoo.com/#symfony

   irc.freenode.net/#symfony...
YUI Documentation


http://developer.yahoo.com/yui/3/
 128 Functional Examples
 API Documentation
A	
  Query	
  Language	
  for	
  the	
  Web




   SELECT	
  	
  *	
  FROM	
  INTERNET
Before YQL

Thousands of web services that provide
valuable data
Require developers to read documentation
and form URLs/qu...
Y! Open Stack – YQL
SQL-Like Language
 Synonymous with Data access
 Familiar to developers
 Expressive enough to get the r...
YQL – Open Tables
Twitter
Google
Facebook
Friendfeed
Wesabe
Whitepages
Zillow

On github - http://github.com/yql/yql-table...
Y! Developer Network –
    Documentation
More than 275 functional examples
 http://developer.yahoo.com/yui/examples/
YSlow...
LAMP Meetup - Symfony & YUI3
LAMP Meetup - Symfony & YUI3
LAMP Meetup - Symfony & YUI3
LAMP Meetup - Symfony & YUI3
LAMP Meetup - Symfony & YUI3
LAMP Meetup - Symfony & YUI3
LAMP Meetup - Symfony & YUI3
Upcoming SlideShare
Loading in...5
×

LAMP Meetup - Symfony & YUI3

4,505

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,505
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
41
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "LAMP Meetup - Symfony & YUI3"

  1. 1. Dustin Whittle - dustin@yahoo-inc.com
  2. 2. Who am I? Yahoo! – Application Platform + Dev Network Worked with Y! Answers, Delicious, Y! Bookmarks, Y! Widgets, Yahoo! Application Platform Working with symfony since open source symfony Core Team Member Responsible for symfony at Yahoo!
  3. 3. symfony-project.com | developer.yahoo.com/yui
  4. 4. Users Load Balancers Frontend Apache PHP ysymfony / YUI Custom Modules APC, PEAR, PECL, Custom Extensions Backend MySQL/Oracle Web Services Ad API User API FreeBSD 4.x/6.x, Linux 2.6.x
  5. 5. Why use a frontend platform? Rasmus says “frameworks are not well suited for Y!” Build applications to requirements Do exactly what you need: no more, no less Understand that frameworks add overhead Choosing functional components is a better fit Despite choosing open source or building your own Everyone uses a framework If you use open source, you get maintenance for free
  6. 6. Why use a framework? Another software layer (ysymfony, yphp, yapache) Factors out common patterns Code Layout, Configuration, URL Routing ORM / Data Access Authentication / Security (XSS/CSRF) Form Widgets / Validation / Repopulation Internationalization / Localization Debugging and Testing utilities Encourages good design Abstraction > Consistency > Maintainability
  7. 7. YUI3 The syntax is more terse, allowing you to write more compact code using techniques like chaining. The API is selector-driven, which allows you to target page elements flexibly. The library is even more modular and granular than before, so you only put code on the page for features you need.
  8. 8. YUI3 Lighter Don't load what you don't need Don't write code more than once, use it again Easier Consistent API Base, Selector, Widget, IO/Get/DataSource Convenience each, bind, nodelist, queue, chainability, general sugar Faster Opportunity to re-factor core performance pain points
  9. 9. What is symfony? A full stack MVC Framework Written in OOP PHP5 Developed by a French company, Sensio Labs Released open source in October 2005 Licensed under MIT license A large community of active developers A unit + functional testing library, LIME
  10. 10. The Big Picture A complete platform for building web applications from frameworks PHP Framework JavaScript Framework CSS Framework UI Design Patterns + Best Practices Development Tools (logger, profiler, debugger, docs) Unit + Functional Testing Frameworks (LIME /
  11. 11. Open Source Communities
  12. 12. Who uses ysymfony/yui?
  13. 13. symfony is a cohesive and decoupled set of PHP classes
  14. 14. symfony Platform
  15. 15. The symfony framework is based on the symfony platform
  16. 16. symfony Framework
  17. 17. Model-View-Controller
  18. 18. Some people think frameworks are slow and trap you in a box.
  19. 19. Performance?
  20. 20. symfony in features MVC Design + Project/Application Structure Cascading Configuration System (YAML -> PHP) Environments – Dev, Prod, Test, QA, Staging Flexible view layer – layouts, partials, components Task/CLI System Internationalization + Localization Support Form / Widget / Validation System Security – CSRF + XSS Protection + User Management Caching – APC, Memcache, File, Database Testing Framework – LIME Unit + Functional Testing
  21. 21. Symfony vs ? Make your choice based on the requirements of the project Pick a framework or just a component
  22. 22. Getting Started pear channel-discover pear.symfony-project.org pear install symfony/symfony mkdir ~/dev/ysfproject; cd ~/dev/ysfproject symfony generate:project ysfproject symfony generate:app frontend symfony generate:app frontend
  23. 23. symfony CLI + Tasks
  24. 24. sfEventDispatcher // sfPatternRouting $callback = array($this, ’filterParameters‘); $dispatcher->connect(’request.filter_parameters‘, $callback); // sfWebRequest $event = new sfEvent($this, ‘request.filter_parameters’); $dispatcher->filter($event, $parameters); sfPatternRouting and sfWebRequest are decoupled « Anybody » can listen to any event
  25. 25. application.log application.throw_exception context.load_factories request.filter_parameters user.change_culture controller.page_not_found response.filter_content view.cache.filter_content *.method_not_found
  26. 26. require '/home/y/share/pear/symfony/autoload/ sfCoreAutoload.class.php'; sfCoreAutoload::register(); $dispatcher = new sfEventDispatcher(); $routing = new sfPatternRouting($dispatcher); $routing->connect(new sfRoute('hello', '/hello/:name')); $request = new sfWebRequest($dispatcher); $response = new sfWebResponse($dispatcher); $content = 'Hello '.$request->getParameter('name', 'World'); $response->setContent($content); $response->send();
  27. 27. symfony Configuration Based on YAML Support for environments prod, dev, test, qa, staging, ... Dimension System Allows easy customization of any configuration files and templates Anything can be a dimension Intl, Brand, Host, Data center Dimensions are Flexible Inheritance = Override only what you need to Dimensions can be chained together
  28. 28. homepage: url: / param: { module: common, action: homepage } item_get: url: /api/v1/item/:id param: { module: item, action: get} requirements: { id: ‘d’ }
  29. 29. frontend/modules/common/actions/actions.class.php class commonActions extends sfActions { public function executeHomepage($request) { $this->templateFooVar = ‘Hello World’; } } frontend/modules/common/templates/homepageSuccess.php <?php echo $templateFooVar; ?>
  30. 30. symfony view layer Actions can render different views, a partial, or a component (think: same controller for ajax/full view) View.yml Configures css, js, meta, layout (app/module/action) Layouts – Most web apps consist of full page and popup layout A partial is a static template fragment
  31. 31. class SigninForm extends sfForm { public function configure() { $this->setWidgets(array( 'username' => new sfWidgetFormInput(), 'password' => new sfWidgetFormInput(array('type' => 'password')), 'remember' => new sfWidgetFormInputCheckbox(), )); $this->setValidators(array( 'username' => new sfValidatorString(), 'password' => new sfValidatorString(), 'remember' => new sfValidatorBoolean(), )); $this->validatorSchema->setPostValidator(new UserValidator()); $this->widgetSchema->setNameFormat(’user[%s]'); } }
  32. 32. <form action=“<?php echo url_for(‘user/signin’);” method=“post”> <?php echo $form; ?> </form>
  33. 33. $this->form = new SigninForm(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('user')); if ($this->form->isValid()) { $values = $this->form->getValues(); $this->getUser()->signin($values['user']); } }
  34. 34. symfony / YUI YUI integration is provided in the form of template helpers AJAX Buttons Tabs Overlays Debug Toolbar Integration
  35. 35. Debugging Tools
  36. 36. Deployment Tools Aggregate and minify stylesheets and javascripts Rewrite templates, css, js for CDN (YCS) Generate translations for configurations + templates + js Aggregate core classes + hardcode paths + remove debug Run lint, unit, functional tests Deployment via rsync
  37. 37. LIME Unit Testing ./symfony test:unit
  38. 38. $t = new lime_test(9, new lime_output_color()); // create configuration $t->comment('check configuration'); $frontendConfiguration = ProjectConfiguration::getApplicationConfiguration('frontend', 'test', true); $t->isa_ok($frontendConfiguration, 'frontendConfiguration', 'ProjectConfiguration::getApplicationConfiguration() returns a valid frontend application configuration instance.'); // check plugins enabled $t->comment('check application plugins'); $t->is_deeply($frontendConfiguration->getPlugins(), array(1 => 'sfDoctrineGuardExtraPlugin', 2 => 'sfDoctrineGuardPlugin', 3 => 'sfDoctrineManagerPlugin', 4 => 'sfDoctrinePlugin', 5 => 'sfDoctrineViewCachePlugin', 6 => 'sfFacebookPlugin', 7 => 'sfFormExtraPlugin', 10 => 'sfTaskExtraPlugin', 11 => 'ysfOpenPlugin', 12 => 'ysfYUIPlugin'), 'frontendConfiguration->getPlugins() returns a valid list of application plugins.'); // create instance $t->comment('check context instance'); $frontendContext = sfContext::createInstance($frontendConfiguration); $t->isa_ok($frontendContext, 'sfContext', 'sfContext::createInstance() returns a valid context instance from configuration.');
  39. 39. LIME Functional Testing ./symfony test:functional backend
  40. 40. $browser = new frontendTestFunctional(new sfBrowser()); $browser->get('/')-> with('view_cache')->begin()-> isCached(false)-> end()-> with('user')->begin()-> isCulture('en')-> end()-> with('request')->begin()-> isParameter('module', 'stream')-> isParameter('action', 'activity')-> end()-> with('response')->begin()-> isStatusCode(200)-> isHeader('Content-Type', 'text/html; charset=utf-8')-> checkElement('style[type="text/css"]')-> checkElement('div#y-doc')-> checkElement('div.yui-skin-sam')-> checkElement('div#y-doc div#hd')-> checkElement('div#y-doc div#hd div#nav')-> checkElement('div#y-doc div#bd')-> checkElement('div#y-doc div#bd div#y-content')-> checkElement('div#y-doc div#ft')-> checkElement('script[type="text/javascript"]')-> end();
  41. 41. YUI Unit Testing
  42. 42. YUI({combine: true, timeout: 10000}).use("node", "console", "test",function (Y) { Y.namespace("example.test"); Y.example.test.AdvancedOptionsTestCase = new Y.Test.Case({ name: "Advanced Options Tests", _should: { fail: { testFail: true }, error: { testGenericError: true }, ignore : { testIgnore: true } }, testFail : function() { Y.Assert.fail("Something bad happened."); }, testGenericError : function() { throw new Error("Generic error"); }, testIgnore : function () { alert("You'll never see this."); } }); var r = new Y.Console({ verbose : true, newestOnTop : false }); r.render('#testLogger'); Y.Test.Runner.add(Y.example.test.AdvancedOptionsTestCase); Y.Test.Runner.run(); });
  43. 43. symfony Documentation http://www.symfony-project.org/doc/ Practical symfony - Jobeet The Definitive Guide to symfony The symfony Reference Guide symfony Forms in Action Doctrine ORM for PHP Cookbooks + Cheat sheets + Wiki API Documentation
  44. 44. http://www.symfony-project.org/jobeet/ 1_2/ A set of 24 tutorials Each tutorial is meant to last one hour, and explains the step by step development of a web application with symfony, from A to Z. http://www.jobeet.org/
  45. 45. Support Forums http://www.symfony-project.com/forum IRC irc.corp.yahoo.com/#symfony irc.freenode.net/#symfony Mailing List ysymfony-users@yahoo-inc.com symfony-users@googlegroups.com
  46. 46. YUI Documentation http://developer.yahoo.com/yui/3/ 128 Functional Examples API Documentation
  47. 47. A  Query  Language  for  the  Web SELECT    *  FROM  INTERNET
  48. 48. Before YQL Thousands of web services that provide valuable data Require developers to read documentation and form URLs/queries. Data is isolated and can not be combined Needs combining, tweaking, shaping even after it gets to the developer.
  49. 49. Y! Open Stack – YQL SQL-Like Language Synonymous with Data access Familiar to developers Expressive enough to get the right data Self Describing - show, desc table Allows you to query, filter and join data across Web Services.
  50. 50. YQL – Open Tables Twitter Google Facebook Friendfeed Wesabe Whitepages Zillow On github - http://github.com/yql/yql-tables/
  51. 51. Y! Developer Network – Documentation More than 275 functional examples http://developer.yahoo.com/yui/examples/ YSlow + Performance Rules http://developer.yahoo.com/performance YUI Blog http://yuiblog.com/ Mailing List @ Yahoo! Groups
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×