Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-17-2008, 06:46 PM
Junior Member
 
Join Date: Oct 2007
Posts: 26
Default Best Practices for bootstrap and confiuration

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();
	}

?>
This is some code from a test app that I am working on. I know I need to handle the exception handling elsewhere and deal with it accordingly, but it was just to get me started.

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:10 PM.