Save 37% off PRO during our Black Friday Sale! »

Introduction to the Yii Framework

98e5a25fce195ae62bb1bad35b270f51?s=47 Larry Ullman
November 02, 2012

Introduction to the Yii Framework

First given at True North PHP 2012, Toronto, Canada.
Note that more than half the presentation was actual live coding and development (and therefore not shown in these slides).

98e5a25fce195ae62bb1bad35b270f51?s=128

Larry Ullman

November 02, 2012
Tweet

Transcript

  1. INTRODUCTION TO THE YII FRAMEWORK, VERSION 2 LARRY ULLMAN, @LARRYULLMAN

    TRUE NORTH PHP NOVEMBER 2, 2012 YII.LARRYULLMAN.COM Friday, November 16, 12 Good afternoon and welcome to my presentation on the Yii framework. In creating this presentation, I asked myself: What is it that I want to say about the Yii framework?
  2. YII IS NOT THE BEST PHP FRAMEWORK. Friday, November 16,

    12 First, and most importantly, you should walk out of here knowing that Yii is not the best PHP framework. [[PAUSE]] No, what I meant to say is that Yii IS the best PHP framework. Actually, I hope you all know, it’s a stupid suggestion either way. Although if it helps...
  3. YII IS THE BEST PHP FRAMEWORK. Friday, November 16, 12

    First, and most importantly, you should walk out of here knowing that Yii is not the best PHP framework. [[PAUSE]] No, what I meant to say is that Yii IS the best PHP framework. Actually, I hope you all know, it’s a stupid suggestion either way. Although if it helps...
  4. FALSE •ARGUE THAT YII IS THE BEST FRAMEWORK •ARGUE THAT

    YII IS BETTER THAN X FRAMEWORK •CONVINCE YOU TO SWITCH FRAMEWORKS $MYGOALSTODAY === Friday, November 16, 12 So what am I here for? [[GO THROUGH FALSE]] I’m not a framework expert. I haven’t tried them all and I certainly haven’t mastered them all. So what am I doing here? [[GO THROUGH TRUE]] I think we all know there’s a huge benefit in knowing more than one framework. Perhaps that second framework should be Yii, if it’s not already. For me, for those of you wondering, Yii is my first framework, and maybe Zend is my second maybe.
  5. FALSE TRUE •ARGUE THAT YII IS THE BEST FRAMEWORK •ARGUE

    THAT YII IS BETTER THAN X FRAMEWORK •CONVINCE YOU TO SWITCH FRAMEWORKS •TELL YOU WHY YOU MIGHT LIKE YII •TELL YOU WHY I LIKE YII •GIVE YOU AN OVERVIEW OF WHAT YII HAS TO OFFER •SHOW CODE $MYGOALSTODAY === Friday, November 16, 12 So what am I here for? [[GO THROUGH FALSE]] I’m not a framework expert. I haven’t tried them all and I certainly haven’t mastered them all. So what am I doing here? [[GO THROUGH TRUE]] I think we all know there’s a huge benefit in knowing more than one framework. Perhaps that second framework should be Yii, if it’s not already. For me, for those of you wondering, Yii is my first framework, and maybe Zend is my second maybe.
  6. WHAT YOU MIGHT LIKE MODEL-VIEW-CONTROLLER (MVC) ACTIVE RECORD (AR) &

    PHP DATA OBJECTS (PDO) FLEXIBLE AND EXTENDIBLE ALLOWS FOR ADVANCED USES SCALES WELL JQUERY BUILT-IN Friday, November 16, 12 Yii 1 requires PHP 5.1; Yii 2 will require PHP 5.3, which introduces namespaces & anonymous functions Active Record for Object Relational Mapping (ORM) Flexibility: swap ORM, db library, template library (e.g., to Twig), etc.
  7. WHAT I LIKE PHP 5 ONLY DOES A LOT OF

    THE WORK FOR YOU ACCESSIBLE, YET POWERFUL VERY CONFIGURABLE WORKS WELL WITH THIRD-PARTY SOFTWARE FEELS RIGHT Friday, November 16, 12 spend 80% of your time working on what makes the site unique great for beginners, but not unlimited for advanced programmers use Zend Framework in parts Reminds me of Ruby on Rails
  8. TODAY’S PRESENTATION GETTING STARTED BASIC EDITS AND SCAFFOLDING CORE COMPONENTS

    ADVANCED CONCEPTS LOOKING AHEAD AT YII 2 Friday, November 16, 12 Mixture of code and overview Will build up part of an app live Won’t be looking at slides for most of the session Could embarrass myself
  9. GETTING STARTED Friday, November 16, 12

  10. GETTING STARTED TESTING THE REQUIREMENTS CREATING A SITE SHELL TESTING

    WHAT YOU HAVE GETTING FAMILIAR Friday, November 16, 12 Show requirements test image Yii 1 vs Yii 2 The Bootstrap File The Site's Folders How Yii Handles a Page Request
  11. BASIC EDITS AND SCAFFOLDING Friday, November 16, 12

  12. BASIC EDITS AND SCAFFOLDING INITIAL CONFIGURATION GENERATING MODELS GENERATING CRUD

    TESTING WHAT YOU HAVE NOW Friday, November 16, 12 Connecting to the Database Managing URLs Logging Enabling Gii Create the Database Generating Models Generating CRUD Testing What You Now Have
  13. CORE COMPONENTS Friday, November 16, 12

  14. MVC MODEL => DATA & BUSINESS RULES VIEW => PRESENTATION

    (HTML) CONTROLLER => AGENT Friday, November 16, 12 Yii generates relations Views can renderPartial
  15. CCOMPONENT CLASS GETTERS & SETTERS EVENTS BEHAVIORS (MIXINS) Friday, November

    16, 12 The CComponent class is one of the basic building blocks in Yii. Almost every other class extends it. CComponent provides a number of key features, including getters and setters, events, and behaviors.
  16. AUTHENTICATION & AUTHORIZATION USER APPLICATION COMPONENT USER AVAILABLE VIA YII::APP()->USER

    LOGGED IN OR NOT: IF (!YII::APP()->USER->ISGUEST) { EXTENDABLE Friday, November 16, 12 You can also do auth via OpenID LDAP, Twitter, Facebook by extending CUserIdentity
  17. WIDGETS GRIDVIEW LISTVIEW DETAILVIEW MENU JQUERY UI Friday, November 16,

    12 Used to help with HTML generation Built in, namespaced under zii Examples: GridView, Menu, ListView, DetailView
  18. EXTENSIONS BOOTSTRAP AUTHORIZATION YIIMONGODBSUITE TINYMCE Friday, November 16, 12 More

    elaborate Often third-party http://www.yiiframework.com/extensions/
  19. ADVANCED CONCEPTS Friday, November 16, 12 Query Builder http://www.yiiframework.com/doc/guide/1.1/en/database.query-builder

  20. MODULES SELF-CONTAINED MINI-APP STORE IN PROTECTED/MODULES NESTABLE MODULEID/CONTROLLERID/ ACTIONID Friday,

    November 16, 12 Self-contained unit, like a complete Yii application within the application (but cannot be used on its own) Examples: admin, forum, store Gii can get you started New route
  21. THIRD-PARTY LIBRARIES Friday, November 16, 12

  22. CACHING MEMCACHE APC XCACHE EACCELERATOR ZEND DATA CACHE FILE DB

    Friday, November 16, 12 Yii::app()->cache Can store single piece of data, pages or page fragments, or database stuff
  23. WHAT ELSE? INTERNATIONALIZATION TESTING PHPUNIT SELENIUM CONSOLE APPLICATIONS WEB SERVICES

    Friday, November 16, 12 l18n: message translation, date, time, & number formatting PHPUnit 3.5, Selenium 1 Provides database fixture class
  24. LOOKING AHEAD AT YII 2 Friday, November 16, 12

  25. LOOKING AHEAD AT YII 2 COMPLETE REWRITE; MORE BEAUTIFUL AND

    CURRENT CODE NEW PHP FEATURES USE NAMESPACES FOR ITS CLASSES BETTER MVC DESIGN WITH MORE SUPPORT FOR CONSOLE APPS CONSOLE APPS MAKE IMPROVEMENTS FOR WORKING WITH DATABASES, INCLUDING ACTIVE RECORD AND QUERY BUILDER Friday, November 16, 12
  26. INTRODUCTION TO THE YII FRAMEWORK, VERSION 2 LARRY ULLMAN, @LARRYULLMAN

    TRUE NORTH PHP NOVEMBER 2, 2012 YII.LARRYULLMAN.COM Friday, November 16, 12