Hi Andries,
I've been working on a setup like this
For the ZF using project I'm currently working on ...a CMS type
thingy... I wanted to have a "base/layout" type controller that is
then extended by other controllers. So initially I had...
LayoutController extends Zend_Controller_Action
...which was then used e.g...
IndexController extends LayoutController
ArticlesController extends LayoutController
However I realised for the front end that the IndexController usually
only has one main task; to display the home page. So now I use that
as the base controller:
class IndexController extends Zend_Controller_Action
{
protected $_view;
protected $_auth;
protected $_config;
protected $_database;
...etc
public function init()
{
$this->_auth = Zend::registry( 'auth' );
$this->_view = Zend::registry( 'view' );
$this->_config = Zend::registry( 'config' );
$this->_database = Zend::registry( 'database' );
...etc
}
....do other stuff
}
then...
class ArticlesController extends IndexController
{
private $_content_table;
public function init()
{
parent::init();
Zend_Db_Table::setDefaultAdapter( $this->_database );
$this->_content_table = new ContentTable();
}
...do other stuff
}
For the backend I have...
AdminController extends Zend_Controller_Action
then eg...
ContentController extends AdminController
So both AdminController and IndexController can take care of the
specific setup for the different areas and I only need to use one
bootstrap file and one .htaccess. Also the urls are straightforward:
/index/ --> IndexController
/article/whatever --> rewrite routed to ArticlesController which
extends IndexController
/admin/ --> AdminController ...shows the admin "dashboard"
/content/add/ --> ContentController which extends AdminController
I'm still waiting to find the weak points of this approach but it
seems to be holding up so far.
Nick
Hello all,
I was wondering, what do you guys consider best practice for
setting up a frontend and a backend for a project.
- Do you work with a single bootstrap file, or multiple bootstrap
files (eg. one for frontend and one for backend)
- How do you deal with your controllers in this situation? Because
application logic in backend and frontend usually differ.
- How do you setup your .htaccess in this situation? I want to have
"/admin/" go to the backend, so "/admin/" cannot be dispatched as a
controller...
Best regards,
--
Andries Seutens
http://andries.systray.be
i18n Locale Team is looking for your help. Volunteers are always
welcome to contribute their feedback, bug fixes, suggestions for
enhancements and improvements, experimental patches, and especially
their ideas on the fw-i18n mail list.
Are you enjoying the wiki manual? They are frequently updated and
incubator documentation is also included!
Live manual: http://framework.zend.com/wiki/display/ZFDOCDEV
Incubator manual: http://framework.zend.com/wiki/display/ZFDOC
--------------------------------------------
Ingredients Australia
http://www.ingredients.com.au
--------------------------------------------