Lately I’ve created a variety of projects and I’ve modified my command structure just slightly.  This new method has a couple minor advantages, but still utilizes the essentials of the command structure.

The overall file structure of a project looks something like this:

  • common.inc.php
  • header.inc.php
  • footer.inc.php
  • classes/class.inc.php
  • view.php
  • c_controller.php

In the new view.php and c_controller.php files, I’m still using my command structure, but the controller is contained (more or less) exclusively within the c_controller.php file.  This lets me include only the common file (instead of the header which then includes the common file), and lets me have a nice redirect statement at the bottom of the file to redirect back to wherever the user was before the controller was called, which makes the code even more easily reusable.

common.inc.php

This is the core file that allows your entire system to run.  Includes to autoloaders, globals, settings, required functions, etc., all live here.

header.inc.php

This file generally starts with an include to the common.inc.php file, then starts building out the beginning of the HTML.  That includes includes for javascript and css files as well as either housing the nav directly in this file, or if it’s more complex (or variable), includes the nav as necessary.  The view.php page that includes this header.inc.php file can also set various variables which are examine here such as $login_required or $use_ck_editor.

footer.inc.php

Closes up the header’s HTML, might append memory usage or page run-time statistics if needed or desired.

classes/class.inc.php

I generally have one class file per MySQL table plus other classes for significant object-oriented functions.  UI, string, array, and date object classes can all live in here as well.  Example filenames might be user.inc.php, job.inc.php, company.inc.php.

view.php

This will display whatever content you’re trying to show to the user.  It can optionally use the command structure as well.  Typically this is some kind of a list-of-elements page, or a view-detail or edit-item page.  Example file names might be users.php, user.php, jobs.php, job_edit.php, etc.

c_controller.php

This is generally executed from buttons or links clicked on view.php pages, will process some kind of work, and redirect the user back to a view.php page.  This file always uses the command structure so that multiple control segments can live within a single file.  If the user needs to land on a particular page, that can be specified in the command segment, or the specified landing page can be omitted and the script will redirect the user back to the page they were previously on.  Example file names might be c_user.php, c_job.php, c_company.php, etc.

September 22nd, 2015

Posted In: Uncategorized

Leave a Comment

After banging my head on the desk for far longer than I’d like to admin, I finally figured out the really simple reason my installation of a SSL certificate on a Amazon Linux EC2 instance wasn’t working: Apache has a separate config file for SSL information that is not in the standard /etc/httpd/conf/httpd.conf file.

It’s in /etc/httpd/conf.d/ssl.conf.

Many many thanks to http://jafty.com/blog/installing-godaddy-ssl-certificate-on-amazon-ec2/ for pointing me in the right direction!

Also, just as a reminder for myself, if you’re using a GoDaddy-based SSL certificate that has the “bundle.crt” file, use the SSLCACertificateFile not the SSLCertificateChainFile option in the ssl.conf file.

May 7th, 2015

Posted In: Uncategorized

Leave a Comment

We’re all familiar with MVC.  Model, view, controller.  What if it should actually be MSVC?  Model, Security, View, Controller?

Here’s what I’m thinking: In traditional MVC, the question of where to put in security is vague.  The worst security may be applied at the view layer, but anyone that knows how to hack around a web form can probably bypass it.  Controller-based security would work better, but what if you have a complex security-permissions system?  Adding it at the Model level probably doesn’t give you enough context to understand whether or grant the request or not.

So I’m thinking, insert a layer above the model, below the controller that’s “Security/Permissions”.  The model would pass it’s data and requests to the security system, which if approved, would be passed to the model.  If permission is not granted, the security layer can pass back various complaints to the controller which will then display those in the view.

I doubt I’ll have an opportunity to try writing a project using this idea anytime soon, but I wanted to get it down on “paper” while it was still fresh.

August 13th, 2014

Posted In: Uncategorized

Leave a Comment

ta-why-internet-explorer-must-die-0

May 17th, 2013

Posted In: Uncategorized

Leave a Comment

The-Life-of-a-Software-Engineer

April 6th, 2013

Posted In: Uncategorized

Leave a Comment