|
|||
|
Hello everyone,
I am pretty new to ZF, and I have been working through some examples and tutorials. I really like the "loose" feel of the framework. I apologize in advance if this series of questions has been asked before, I didn't really see anything that answered them...perhaps I just overlooked them. What I would like to know is this, is there a best practice for how to setup a bootstrap? Something that is secure, scalable, and suitable for small to medium size enterprise website? I realize that this is just some test code that I am tinkering with, but I would really like to get a feel for what others out there are doing. Are you creating base controllers? What kind of common code is going into your base controller? What kind of things are you doing for plugins? Helpers? I guess I just want to get a good idea of the scope of things that are being done and the best way (if one even exists) to do them within the context of ZF and PHP. Code:
<?php
$lib_paths = array();
$lib_paths[] = '..' . DIRECTORY_SEPARATOR . 'library';
$lib_paths[] = '..' . DIRECTORY_SEPARATOR . 'application';
$inc_path = implode(PATH_SEPARATOR, $lib_paths);
set_include_path($inc_path);
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Controller_Front');
Zend_Loader::loadClass('Zend_Controller_Router_Rewrite');
try
{
Zend_Loader::loadClass('Zend_Controller_Front');
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->setParam('noErrorHandler', true);
$frontController->addModuleDirectory('/var/www/zfApp/application/modules');
$frontController->dispatch();
} catch (Exception $exp) {
$contentType = 'text/html';
header("Content-Type: $contentType; charset=utf-8");
echo 'An unexpected error occured.';
echo '<h2>Unexpected Exception: ' . $exp->getMessage() . '</h2><BR /><pre>';
echo $exp->getTraceAsString();
}
?>
What kinds of things can I do to make this code better? I'm not a PHP expert by any stretch, but I do have a little experience with it. My project is currently setup to use modules. my directory structure looks something like this. Code:
application
|-- config
`-- modules
|-- admin
| |-- config
| |-- controllers
| | |-- IndexController.php
| |-- models
| `-- views
| |-- filters
| |-- helpers
| `-- scripts
| `-- index
| |-- extract.phtml
| |-- index.phtml
`-- default
|-- config
|-- controllers
| |-- IndexController.php
| |-- UserController.php
|-- models
| |-- User.php
`-- views
|-- filters
|-- helpers
`-- scripts
`-- index
|-- extract.phtml
|-- gmap.phtml
|-- index.phtml
|
`-- library
|
`-- Zend
|
`-- Common
|
`-- www
|
`-- ...
I would also like to add Smarty and Propel at some point. But for right now, I would like to get a solid foundation to build upon along with a strong understanding of the framework. Any suggestions or recommendations would be most appreciated. Thanks in advance |
![]() |
| Thread Tools | |
| Display Modes | |
|
|