yii framework - do we really need another php framework?
TRANSCRIPT
Do we really need another
PHP Framework?
About Me
Professionally developing software since 2003
Focus on web, mobile and game development
Into the gaming industry since 2008
Former Lead developer Web Games @ Gameforge
Now gun for hire: Eckert Internet Services
Yii?
Yii is an acronym for Yes it is!, the answer to the most likely asked questions regarding a framework:
Pretty self-confident, hm?
Is it fast?
Is it secure?
Is it professional?
Is it right for my next project?
Yiiwhat?
Started in 2008 by former PRADO developer Qianq Xue
Team of 7 core developers
No release for some months but active maintenance on Github
Facebook page & Google Group
Small but professional community
Features at a glance
RAD Widgets (View helpers, ListView, GridView)
AR, DAO, Query Builder, Database Migration
Massive Extensibility (DI, Behaviours, Events, Hooks, Modules ) => Useful Extensions!
Nice Routing
Good security mechanisms
Scaffolding and Console Applications
lean, clean, reusable code
RAD Widgets
Easy menu
GridView of (model)data
Configurable in detail, or use as is!
RAD Widgets II
Instead of stand-alone widgets there are also widgets that work on your HTML
Active Record
Work with your database in an object oriented fashion
Active Record II
Yii's AR is quite sophisticated!
Active Record Relations
Relations are easy-peasy
Active Record Scopes
Define WYG (What you get)
Active Record Behaviors
Define how it acts!
So Active Record is the holy grail!
Active Record is convenient
BUT: DO NOT use AR on data driven tables (like logs or tables where the throughput is high!)
Every row is reflected as an object
Think!
If the usecase doesn't favour AR, use DAO!
Power Responsibility
Data Access Objects
Use it if you need lots of datasets at once.
Conclusion AR vs. DAO
AR is convenient to use
Most widgets support AR (but also DAO in some ways)
Code generation through Gii
If you have tables where lots of records are accessed at once, use DAO!
Don't stop to think because it's easy to work with!
Hooks
Every CComponent (almost everything in Yii) calls hooks before/after specified actions:beforeValidate/afterValidate
beforeSave/afterSave
beforeDelete/afterDelete
beforeFind/afterFind
beforeRender/afterRender
uncomplete list, also fired as events.
Need to react? Just hook in!
Again: Think!
Hooks and Events can trigger many actions without caring about them (Observer Pattern). So react on them wisely!e.g. User registers:Action to send mail to user is triggered
Action to send mail to admin is triggered
Creating a user profile
Generating a pdf invoice is triggered
...
Security - XSS
Just use the proper Widgets and methods:
Security - XSRF
Activate XSRF token
Use POST requests for important actions
(like deleting, adding etc.)
That's all you need to do!
Extensions / Modules
Modules are self-contained MVCs and nestable
Can interact with core application. Nice for administrative frontend, JSON webservice etc.
Lots of useful extensions already available
Console Applications
Most likely: Cronjobs
Friendly console:
Implement in a MVC like fashion
Embedded Console Applications
Generate message files from application (l8n)
Generate new app skeleton
Migrate database command
and some shell commands (code gen.)
And more...
Easy Internationalization / Localisation
ACL / RBAC (lots of options and possibilities)
Caching on certain levels
PHP-Unit / Selenium Support
Almost ALL Core Components are replacable by DI (Request,
Session, Cookie, )
=> maximum flexibility
Do we really need another
PHP Framework?
YES!
Questions?
? ? ? ?
Thank you!
@nerdlibfront
https://www.xing.com/profile/Joachim_Eckert
www.eisit.de