5. CAKEPHP
WHO LOVES YA, BABY?
5
Saturday, May 23, 2009
6. CAKEPHP
INTRODUCTION
• “Simple is Good”
• Mental “point and click” in applications
• Lays out an example structure for you
• Works for you on two levels - websites and cli
• bake puts the “rapid” in RAD
6
Saturday, May 23, 2009
7. CAKEPHP
WHAT’S IN THE BOX
• Access control • Cookie Handling
• Ajax integration (Prototype) • Email Support
• HTML generation • Request Handling
• XML handling (including RSS feeds) • Javascript Integration
• Caching • Data Pagination
• Session Handling • Text Manipulation
• Security (request filtering) • Date/Time Support
• Command-line functionality (build • Inflection
scaffolding/models/etc)
7
Saturday, May 23, 2009
8. CAKEPHP
RESOURCES
• Manual at CakePHP.org (aka The Cookbook)
• The Forge - project management for CakePHP applications
• The Bakery - all things CakePHP (Tutorials/Behaviors/Case Studies/Plugins/
Helpers/Snippets)
• Extensions for other software like Komodo, Selenium, Firefox
• #cakephp on Freenode (irc)
• The Show - http://live.cakephp.org
8
Saturday, May 23, 2009
9. CAKEPHP
WHAT THE CRITICS SAY
• Wrappers around simple data types
• Claims of bad markup in HTML helpers
• It’s not “Enterprise Capable”
• Poor/confusing documentation
9
Saturday, May 23, 2009
10. CODEIGNITER
SIMPLE AND SPEEDY
10
Saturday, May 23, 2009
11. CODEIGNITER
INTRODUCTION
• Focuses on simplicity (doesn’t get in the way)
• Small, light and easy
• “Install and Go”
• Product of EllisLabs
• Originally for PHP4, changes have been made for PHP5
• Kohana is a PHP5-based fork
11
Saturday, May 23, 2009
12. CODEIGNITER
WHAT’S IN THE BOX
• Database integration • FTP Support
• Encryption • Pagination
• Form validation • Image Manipulation
• HTML rendering • Calendars
• Session handling • Input/Output Filtering
• Locale support • Trackbacks
• Templating • Text Formatting (Typography)
• XML-RPC • Custom Configuration
• Zip/Compression • Language/Locale Support
12
Saturday, May 23, 2009
13. CODEIGNITER
RESOURCES
• User Guide at the main site: CodeIgniter.com
• CodeIgniter Forums: CodeIgniter.com/forums
• Community Wiki: CodeIgniter.com/wiki
• Extension for Firefox (user guide)
• TextMate bundle
13
Saturday, May 23, 2009
14. CODEIGNITER
WHAT THE CRITICS SAY
• Difficult to have any sort of “sub applications” in your code
• Lazy loading could cause overhead as libraries grow larger
• Simple included libraries lose some advanced features
• Fewer bundled libraries (no repository like the Bakery to get
more)
14
Saturday, May 23, 2009
16. SOLAR
STRONG AND CONSISTENT
16
Saturday, May 23, 2009
17. SOLAR
INTRODUCTION
• PHP5-only from the start
• Fully-namespaced
• Focus on structure and elegance
• Uses several enterprise development patterns
Data Mapper, ServiceLocator, Query Object, Registry, Lazy Load
• Smaller user base, close-knit development community
17
Saturday, May 23, 2009
18. SOLAR
WHAT’S IN THE BOX
• Access control • Documentation Generation
• Caching • Inflection
• JSON Support • MIME Support
• Logging • SMTP
• Markdown • Database Support
• Web Services • Request Handling
• Input/Output Filtering • Locale Support
• Unit testing • Registry
18
Saturday, May 23, 2009
19. SOLAR
RESOURCES
• Main site at SolarPHP.com
• Community Blog at SolarPHP.com/blog
• Solar Wiki at SolarPHP.org
• Solar Manual at SolarPHP.org/manual
• #solarphp on the Freenode (irc)
19
Saturday, May 23, 2009
20. SOLAR
WHAT THE CRITICS SAY
• Poor documentation
• Not enough unit testing coverage
• Different sort of structure (controller/view and model)
• Slower release cycle
• Much lower adoption
20
Saturday, May 23, 2009
21. ZEND FRAMEWORK
YOU WANT IT? WE GOT IT
21
Saturday, May 23, 2009
22. ZEND FRAMEWORK
INTRODUCTION
• Standards-oriented & strong
• Targets itself towards both the casual developer and
Enterprise level users
• Defined control over source (CLA)
• Only MVC by convention, really a set of components (with
MVC tendencies)
• Large community of developers and users
22
Saturday, May 23, 2009
23. ZEND FRAMEWORK
WHAT’S IN THE BOX
• Flex integration • Authentication • Infocard support
• Exception handling • Caching • MIME Handling
• Form Validation • Code Generation • PDF
• LDAP Interface • Date Handling • REST Interface
• OpenID • Feed Parsing • Akismet Integration
• Dojo Integration • Input/Output Filtering • Popular Web Service Interfaces
• Unit Testing • Google Apps Integration • XML-RPC
• Translation • Currency formatting • Progess Bar
23
Saturday, May 23, 2009
24. ZEND FRAMEWORK
RESOURCES
• Main site at framework.zend.com*
• Manual at framework.zend.com/manual/en
• Quickstart at framework.zend.com/docs/quickstart
• Contributor’s wiki at framework.zend.com/wiki
• #zftalk on Freenode (irc)
* Framework site also includes: case studies, video tutorials and bug tracker
24
Saturday, May 23, 2009
25. ZEND FRAMEWORK
WHAT THE CRITICS SAY
• Technically* not a framework
• Tries to do it all without focusing on certain strengths
• Too much object abstraction
• Loosely coupled components can force you to make links
* Don’t send the Zend Goon Squad for me
25
Saturday, May 23, 2009
26. THE FRAMEWORKS
AT A GLANCE
Framework Components Helpers
CakePHP 7 12
CodeIgniter 25 21
Solar 34 49
Zend Framework 75 22
26
Saturday, May 23, 2009
27. A CLOSER LOOK
INSTALL & DEVELOPMENT
27
Saturday, May 23, 2009
28. INSTALLATION
CAKEPHP
• Load & Go
• Change configuration options
In /app/config:
Database connections, routing, session handling, caching options, access control
• No need to make directories, it’s all included
• Bootstrap and front controller included
28
Saturday, May 23, 2009
29. INSTALLATION
CODEIGNITER
• Dead simple
Sets up controller, helper, model, view, etc directories for you
• Update configuration for your site
• Set up database connection information
• Change any autoloads you might want
Libraries/components loaded for every connection -
useful for things like validation or certain models
29
Saturday, May 23, 2009
30. INSTALLATION
SOLAR
• Not quite as “beginner friendly” as CakePHP/CodeIgniter for
setup
• Requires some manual setup to get the ball rolling
has the “Solar System”
• Unpack the libraries in one place, make the site in another
• Create directories for site/vendor/controllers & related files
/www/htdocs/project/vendor/App
/www/htdocs/project/vendor/External
/www/htdocs/project/vendor/<Controller Name>
30
Saturday, May 23, 2009
31. INSTALLATION
SOLAR - BOOTSTRAP
<?php
session_start();
set_include_path('/www/htdocs/Solar:/www/htdocs/project:/www/htdocs/project/
Test:/www/htdocs/project/Test/External');
require_once('Solar.php');
Solar::start('/www/htdocs/Test.config.php');
$front=Solar::factory('Solar_Controller_Front');
$front->display();
Solar::stop();
?>
31
Saturday, May 23, 2009
33. INSTALLATION
ZEND FRAMEWORK
• Similar in setup to Solar
• A “Do It Yourself ” Framework
• Unpack the framework
• Application can be built wherever
• Make a boostrap
33
Saturday, May 23, 2009
39. CODEIGNITER
THE CODE
Controller - /system/application/controllers/FirstController.php
<?php
class First extends Controller {
function index(){
$this->library->load(‘database’);
$notes=$this->db->get_where(‘notes’,
array(‘note_owner’=>‘ccornutt’));
$to_view=array(
‘title’ => ’My First Controller’,
‘notes’ => $notes;
);
$this->load->view('first_page',$to_view);
}
}
?>
View - /system/application/views/first_page.php
<?php echo $title.”<br>n”;
foreach($notes as $v){
echo $v[‘note_title’]' '.$v[‘note_detail’];
}
?>
39
Saturday, May 23, 2009
40. SOLAR
THE CONFIG
DB Config - Appname.config.php
<?php
$config['Solar_Sql'][‘adapter’]=Solar_Sql_Adapter_Mysql';
$config['Solar_Sql_Adapter_Mysql'] = array(
'host' => 'localhost',
'user' => 'myuser',
'pass' => 'mypass',
'name' => 'mydb',
);
?>
Example Database Table
create table notes (
note_title VARCHAR(100),
note_detail VARCHAR(200),
note_owner VARCHAR(10)
);
40
Saturday, May 23, 2009
41. SOLAR
THE CODE
Controller - source/example/MyApp/App/First.php
<?php
class MyApp_App_First Extends Solar_App_Base {
protected $_action_default = 'index';
function actionIndex(){
$db = Solar::factory('Solar_Sql');
$bind = array(‘owner’=>‘ccornutt’);
$notes= $db->query(‘select * from notes where note_owner
= :owner’,$bind);
$this->to_view=array(
‘title’ => ’My First Controller’,
‘notes’ => $notes;
);
}
}
?>
View - source/example/MyApp/First/View/index.php
<?php echo $this->title.”<br>n”;
foreach($this->notes as $v){
echo $v[‘note_title’]' '.$v[‘note_detail’];
}
?>
41
Saturday, May 23, 2009
42. ZEND FRAMEWORK
THE CONFIG
DB Config - /application/configs/application.ini
; Uses an ini file instead of a .php
[production]
database.adapter = PDO_MYSQL
database.params.dbname = quot;mydbquot;
database.params.username = quot;myuserquot;
database.params.password = quot;mypassquot;
database.params.hostname = quot;localhostquot;
Example Database Table
create table notes (
note_title VARCHAR(100),
note_detail VARCHAR(200),
note_owner VARCHAR(10)
);
42
Saturday, May 23, 2009
43. ZEND FRAMEWORK
THE CODE
Controller - /application/controllers/indexController.php
<?php
class IndexController extends Zend_Controller_Action {
public function indexAction(){
$cfg=new Zend_Config_Ini(‘../application/
app.ini’,‘production’);
$db=Zend_Db::factory($cfg->database);
$result=$db->fetchAll(‘select * from notes’);
$this->view->to_view=array(
‘title’=>'My First Controller',
‘notes’=>$result
);
}
}
?>
View - /application/views/scripts/index/index.phtml
<?php echo $this->title.”<br>n”;
foreach($this->notes as $v){
echo $v[‘note_title’]' '.$v[‘note_detail’];
}
?>
43
Saturday, May 23, 2009
44. COMPARING THE FIRST STEPS
Steps to Steps to
Framework Total Steps
Install* “First Page”
CakePHP 2 3 5
CodeIgniter 2 2 4
Solar 5 3 8
Zend
Framework 4 2 6
* Install can include: unpacking, creating directories and making changes to configuration files.
44
Saturday, May 23, 2009
45. HOW FRIENDLY IS YOUR
FRAMEWORK?
C’MON, SHOW US THE LOVE
45
Saturday, May 23, 2009
46. CAKEPHP
WANTS TO BE YOUR FRIEND
• Installation’s as easy as one, two....well, just two
• Code-based database relationships help keep things straight
hasMany, hasOne, belongsTo, hasAndBelongsToMany
• CLI app of schemas, db dumps and migrations
• Naming conventions keep you out of trouble
46
Saturday, May 23, 2009
47. CODEIGNITER
WANTS TO BE YOUR FRIEND
• Lazy loading lets you chose when & what
• Libraries = add, hooks = change, custom core = replacing
• Keeps you safe with URI restrictions and super-global resets
• Easy upgrading (over-write)
47
Saturday, May 23, 2009
48. SOLAR
WANTS TO BE YOUR FRIEND
• Solar System (cli) gets you up and running fast
• Easy to develop on and for
• Friendly wiki manual keeps the community keep up-to-date
48
Saturday, May 23, 2009
49. ZEND FRAMEWORK
WANTS TO BE YOUR FRIEND
• It loves giving you just what you need
• Customizable everything
• Plays well with others
• It has plenty of other friends out there to help you out (over
10 million and counting)
49
Saturday, May 23, 2009
50. WANNA KNOW WHAT I
THINK?
DISCLAIMER: THESE SUGGESTIONS ARE BASED ON MY PERSONAL EXPERIENCE, ARTICLES, RANDOM PEOPLE ON THE
STREET AND A FEW OTHER BLOGS OUT THERE. THEY MIGHT HAVE BEEN MAKING IT UP FOR ALL I KNOW, BUT THAT’S A
RISK I’M WILLING TO TAKE. AFTER ALL, OPINIONS ARE LIKE...WELL, YOU KNOW. THAT BEING SAID, ENJOY THE LIST!
50
Saturday, May 23, 2009
51. WANT A ROCK SOLID, WELL DEVELOPED
FRAMEWORK THAT ISN’T GOING
ANYWHERE? GO ZEND.
• Standards for the code (CLA)
• Emphasis on strong, well-planned, well-tested code
• Large component base
• Zend as a backer (corporate)
• Strong developer community/strong user community
• Grown exponentially in just a few years
51
Saturday, May 23, 2009
52. NEW TO THE WHOLE MVC THING & WANT A
FRAMEWORK TO HOLD YOUR HAND?
CODEIGNITER’S THE WAY TO GO
• Does what you need without getting in the way
• User guide offers easy, complete documentation
• Pre-provided structure helps you get a handle on where each
part of MVC ends up
• Helpful, active community (forums/wiki)
52
Saturday, May 23, 2009
53. LOOKING FOR POWER WITHOUT A LOT OF
THE HASSLE? CAKEPHP’S YOUR GUY
• Friendly framework with helpful hints
• Pre-built structure let’s you hit the ground running
• Solid base components/tools
• Command-line rounds out feature set
53
Saturday, May 23, 2009
54. WANT SOMETHING TO APPEAL TO THE
PLANNER INSIDE THAT NEEDS BOTH POWER
& STRUCTURE? SHINE A LIGHT ON SOLAR
• Strong and standardized
• Similar interfaces found through out the code
• Uses well-practiced (enterprise) design patterns
• Command line builds project structures
54
Saturday, May 23, 2009
55. THAT’S ALL, GO HOME
JUST KIDDING, YOU CAN STAY FOR THE Q&A
55
Saturday, May 23, 2009
56. ADDITIONAL INFORMATION
Frameworks:
CakePHP - cakephp.org
CodeIgniter - codeigniter.org
Solar - solarphp.com
Zend Framework - framework.zend.com
Contact Information:
ccornutt@phpdeveloper.org
@enygma
Joind.in PHPDeveloper.org
http://joind.in/207 http://phpdeveloper.org
Atmos Energy
http://atmosenergy.com
56
Saturday, May 23, 2009