Zend framework-from-the-command-line
-
Upload
khanh-nl-bantoilatoi -
Category
Software
-
view
76 -
download
0
Transcript of Zend framework-from-the-command-line
![Page 2: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/2.jpg)
Why CLI?
I’ll take CLI over web for tools any day
![Page 3: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/3.jpg)
Three ways to do CLI
• Freestyle
![Page 4: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/4.jpg)
Freestyle
wget http://bugu.local/cli/text
?numToCall=16157158812
&payload=This+is+a+test
We’ve all done this.
![Page 5: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/5.jpg)
Freestyle
curl, wget, etc.
• Handy tools
![Page 6: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/6.jpg)
Freestyle
curl, wget, etc.
• Handy tools
• Easy to “cron” a process
![Page 7: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/7.jpg)
Freestyle
curl, wget, etc.
• Handy tools
• Easy to “cron” a process
• Can usually use existing code as-is
![Page 8: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/8.jpg)
Freestyle
curl, wget, etc.
• Handy tools
• Easy to “cron” a process
• Can usually use existing code as-is
• Unnecessary overhead
![Page 9: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/9.jpg)
Freestyle
curl, wget, etc.
• Handy tools
• Easy to “cron” a process
• Can usually use existing code as-is
• Unnecessary overhead
• Security ramifications
![Page 10: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/10.jpg)
Three ways
• Freestyle
• Zend_Tool
![Page 11: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/11.jpg)
Zend_Tool
• Good tool for what it does
![Page 12: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/12.jpg)
Zend_Tool
• Good tool for what it does
• Difficult to get setup
![Page 13: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/13.jpg)
Zend_Tool
• Good tool for what it does
• Difficult to get setup
• Easy to extend
![Page 14: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/14.jpg)
Zend_Tool
• Good tool for what it does
• Difficult to get setup
• Easy to extend
• Great for a specific type of task
![Page 15: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/15.jpg)
.zf.ini
php.include_path = ".;
D:\xampp\php\PEAR;
d:\zf-full\library;
D:\personal\Projects\tool_test\“
basicloader.classes.0 = "My_TweetProvider“
basicloader.classes.1 = "My_Packager“
basicloader.classes.2 = "My_PharZFProvider"
![Page 16: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/16.jpg)
Zend_Tool
Show Packager.php code
![Page 17: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/17.jpg)
Three ways
• Freestyle
• Zend_Tool
• My Way
![Page 18: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/18.jpg)
My Way
cli application but written using Zend Framework and MVC
(Well, M&C, there’s usually not much V)
![Page 19: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/19.jpg)
Why My Way
• No new skills to learn
![Page 20: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/20.jpg)
Why My Way
• No new skills to learn
• All your favorite friends are there
![Page 21: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/21.jpg)
Why My Way
• No new skills to learn
• All your favorite friends are there
• Easy to repurpose code
![Page 22: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/22.jpg)
bugU
• Make a phone ring from the command line
![Page 23: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/23.jpg)
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();
?>
![Page 24: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/24.jpg)
![Page 25: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/25.jpg)
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
![Page 26: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/26.jpg)
bugU
• Make a phone ring from the command line
• Have to override 3 of the default objects
– Custom Bootstrap
– Custom Request
– Custom Response
![Page 27: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/27.jpg)
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
![Page 28: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/28.jpg)
Show Code Here
Application/BootstrapCLI.php
![Page 29: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/29.jpg)
bugU
• Make a phone ring from the command line
• Have to override 3 of the default objects– Custom Bootstrap
– Custom Request
– Custom Response
• Sample is more complex than necessary to show flexibility– Implemented Views
– Implemented Context Switching
![Page 30: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/30.jpg)
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
![Page 31: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/31.jpg)
Wrap up
• Easy
• Useful
• Fun
![Page 32: Zend framework-from-the-command-line](https://reader031.fdocuments.in/reader031/viewer/2022022203/586fc37a1a28aba24c8b5373/html5/thumbnails/32.jpg)
Who Am I?
Cal Evanshttp://blog.calevans.com
@calevans
http://joind.in/3222