Jump to content

Recommended application structure


NotionCommotion

Recommended Posts

I typically structure my applications something like the following.  I lump general functionality into a given component.  For instance, I might have com_users component which deals with user administration, and implements the ability to view a list of users, view a given user, delete a user, edit a user, etc.  This structure was borrowed long ago from my learning PHP Joomla days which I no longer use.  index.php figures out which component is being accessed, evokes the controller which gets data from the model and sends the data to the view.  The view defined in each component only deals with the central content, and mainTemplate.php deals with the peripheral.

First question.  Is there anything inherently wrong with this approach?

Second question.  I am looking to start using Twig.  Would this same structure work?  I would replace /var/www/html/lib/templates/mainTemplate.php with a Twig file, and replace var/www/components/component1/views/view-1-1.php, etc with Twig files which extends the main Twig template.
 

/var/www/components/component1/controllers/controller-1-1.php
/var/www/components/component1/controllers/controller-1-2.php
/var/www/components/component1/models/model-1-1.php
/var/www/components/component1/views/view-1-1.php
/var/www/components/component2/etc/etc
/var/www/html/lib/templates/mainTemplate.php
/var/www/html/lib/templates/mainCSS.css
/var/www/html/lib/js/someJSforAllComponents.js
/var/www/html/lib/components/component1/js/someJSForComponent1.js
/var/www/html/index.php
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.