際際滷

際際滷Share a Scribd company logo
Zend Framework from the
Command Line
Cal Evans
cal@blueparabola.com
Why CLI?
I¨ll take CLI over web for tools any day
Three ways to do CLI
? Freestyle
Freestyle
wget http://bugu.local/cli/text
?numToCall=16157158812
&payload=This+is+a+test
We¨ve all done this.
Freestyle
curl, wget, etc.
? Handy tools
Freestyle
curl, wget, etc.
? Handy tools
? Easy to ^cron ̄ a process
Freestyle
curl, wget, etc.
? Handy tools
? Easy to ^cron ̄ a process
? Can usually use existing code as-is
Freestyle
curl, wget, etc.
? Handy tools
? Easy to ^cron ̄ a process
? Can usually use existing code as-is
? Unnecessary overhead
Freestyle
curl, wget, etc.
? Handy tools
? Easy to ^cron ̄ a process
? Can usually use existing code as-is
? Unnecessary overhead
? Security ramifications
Three ways
? Freestyle
? Zend_Tool
Zend_Tool
? Good tool for what it does
Zend_Tool
? Good tool for what it does
? Difficult to get setup
Zend_Tool
? Good tool for what it does
? Difficult to get setup
? Easy to extend
Zend_Tool
? Good tool for what it does
? Difficult to get setup
? Easy to extend
? Great for a specific type of task
.zf.ini
php.include_path = ".;
D:xamppphpPEAR;
d:zf-fulllibrary;
D:personalProjectstool_test^
basicloader.classes.0 = "My_TweetProvider^
basicloader.classes.1 = "My_Packager^
basicloader.classes.2 = "My_PharZFProvider"
Zend_Tool
Show Packager.php code
Three ways
? Freestyle
? Zend_Tool
? My Way
My Way
cli application but written using Zend
Framework and MVC
(Well, M&C, there¨s usually not much V)
Why My Way
? No new skills to learn
Why My Way
? No new skills to learn
? All your favorite friends are there
Why My Way
? No new skills to learn
? All your favorite friends are there
? Easy to repurpose code
bugU
? Make a phone ring from the command line
What the Tropo side looks like
<?php
_log('Number To Call:'.$numToCall);
_log('Payload:'.$payload);
call('+'.$numToCall,
array("callerID" => '16155551212',
"timeout" => 30)
);
say ($payload, array('voice'=>'veronica'));
hangup();
call('+16157158812',array('network'=>'SMS'));
say('I sent a message to '.$numToCall.' saying
'.$payload);
hangup();
?>
Zend framework-from-the-command-line
NOT A TROPO AD
? Tropo is pretty cool
? Free for development
? Cheap for production
? Adam Kalsey is pretty dang cool
? Awesome shirts if you can get one
? http://tropo.com
bugU
? Make a phone ring from the command line
? Have to override 3 of the default objects
C Custom Bootstrap
C Custom Request
C Custom Response
Application.ini settings
[cli : production]
bootstrap.path = APPLICATION_PATH "/BootstrapCli.php^
bootstrap.class = "BootstrapCli^
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
Show Code Here
Application/BootstrapCLI.php
bugU
? Make a phone ring from the command line
? Have to override 3 of the default objects
C Custom Bootstrap
C Custom Request
C Custom Response
? Sample is more complex than necessary to
show flexibility
C Implemented Views
C Implemented Context Switching
Show Code Here
Library/Cal/Controller/Request/Cli.php
Library/Cal/Controller/Router/Cli.php
Application/controllers/IndexController.php
Application/controllers/CliController.php
Application/views/scripts/Index/index.phtml
Application/views/scripts/Cli/help.text.phtml
Application/views/scripts/Cli/call.text.phtml
Application/views/scripts/Cli/text.text.phtml
Application/views/scripts/Cli/help.text.phtml
Wrap up
? Easy
? Useful
? Fun
Who Am I?
Cal Evans
http://blog.calevans.com
@calevans
cal@blueparabola.com
cal@calevans.com
AIM:cal@calevans.com
http://joind.in/3222

More Related Content

Zend framework-from-the-command-line