Platinum Partner

Automating Zend MVC Structure

Automating Zend MVC Structure
This is what I use... It's very useful.



setControllerDirectory("../app/controllers");

$front->throwExceptions(true);

#
# Get an Instance For Routing
# $route = $front->getRouter(); // Returns a rewrite router by default
# $route->addRoute(\'user\',
#	new Zend_Controller_Router_Route(\'user/:username\', array(\'controller\' => \'index\', \'action\' => \'test\'))
# );
#
# $route->addRoute(\'product\',
#	new Zend_Controller_Router_Route_Regex(\'product/(\d+)\', array(\'controller\' => \'index\', \'action\' => \'test\'))
# );
#
# $route->addRoute(\'login\',
#	new Zend_Controller_Router_Route_Regex(\'login\', array(\'controller\' => \'index\', \'action\' => \'test\'))
# );
#

# Start the dispatch
$front->dispatch();

?>
';
	# Write the Bootstrap file
	file_put_contents("./". APPLICATION_NAME ."/public/index.php", trim($zend_bootstrap_code));
	
# Write The Index Controller
$zend_index_controller_code = '
 Logic code here...
		$this->view->random_number = rand(0,10);
		$this->view->status = "It works!";
		$this->render("index");
	}
}

?>
';
	# Write the First Index Controller
	file_put_contents("./". APPLICATION_NAME ."/app/controllers/IndexController.php", trim($zend_index_controller_code));


# Write the index view file
$zend_index_view_code = '



  
  Zend Framework


Status: status ?>

Random Number: random_number ?>
'; # Write the First Index View File passthru("mkdir ./". APPLICATION_NAME ."/app/views/scripts/index"); file_put_contents("./". APPLICATION_NAME ."/app/views/scripts/index/index.phtml", $zend_index_view_code); # Create the .htaccess file $zend_htaccess_code = ' RewriteEngine On RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php '; # Write the .htaccess code to disk file_put_contents("./". APPLICATION_NAME ."/public/.htaccess", trim($zend_htaccess_code)); # Delete the Downloaded Framework Directory and tar file passthru("rm -f ./". ZEND_FILE_NAME); passthru("rm -rf ./". basename(ZEND_FILE_NAME, ZEND_FILE_TYPE)); passthru("clear"); echo "\nZend Framework has been created... Done!\n\n"; } ?>
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}