Created
February 17, 2010 12:01
-
-
Save claussni/306541 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ php zendphy.php | |
Hello, World |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// set include path to library | |
set_include_path(implode(PATH_SEPARATOR, array( | |
'/opt/ZendFramework-1.10.1/library', | |
get_include_path(), | |
))); | |
// enable autoloading | |
require_once 'Zend/Loader/Autoloader.php'; | |
Zend_Loader_Autoloader::getInstance(); | |
// fool front controller to avoid complex application setup | |
$front = Zend_Controller_Front::getInstance(); | |
$front->throwExceptions(true); | |
$front->setParam('noViewRenderer', true); | |
$front->setControllerDirectory('.'); | |
// setup custom route for say controller | |
$router = $front->getRouter(); | |
$route = new Zend_Controller_Router_Route( | |
'say/:something/to/:someone', | |
array('controller' => 'say', 'action' => 'get')); | |
$router->addRoute('say', $route); | |
// say controller class | |
class SayController | |
extends Zend_Controller_Action { | |
public function getAction() { | |
$request = $this->getRequest(); | |
$something = $request->getParam('something'); | |
$someone = $request->getParam('someone'); | |
$this->getResponse()->appendBody($something . ', ' . $someone); | |
} | |
} | |
// let front controller dispatch mind shaking url | |
$request = new Zend_Controller_Request_Http('http://helloworldapp/say/Hello/to/World'); | |
Zend_Controller_Front::getInstance()->dispatch($request); | |
echo "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment