1

Summary

Create PHPServer-side scripting language for web development. MVC framework with a front controller design, a MySQLRelational database used to hold website content and search data. database to store content, ComposerUsed to manage the installation of third-party PHP libraries. to manage dependencies and TwigPHP template engine that simplifies the generation of HTML pages. as the templating engine.

Overview

Purpose Establish a framework to support and manage the ongoing development effort.
Goals
Technology MAMPPersonal webserver stack to allow PHP and MySQL development on MacOS. - Apache, MySQLRelational database used to hold website content and search data. and PHPServer-side scripting language for web development., Brackets, ComposerUsed to manage the installation of third-party PHP libraries., TwigPHP template engine that simplifies the generation of HTML pages., GitCommand line tool for keeping track of changes in source files., BitBucketWeb-based service for hosting and sharing Git repositories.
Resources Udemy class “Write PHPServer-side scripting language for web development. Like a Pro: Build a PHPServer-side scripting language for web development. MVC Framework from Scratch” taught by Dave Hollingworth.
(Highly recommended. The MVC framework used for this website comes almost directly from this class. This project writeup is at a high level, the class goes into details of the hows and whys.)

Implementation

  1. Install MAMPPersonal webserver stack to allow PHP and MySQL development on MacOS.

    In order to create development environment on a local machine MAMPPersonal webserver stack to allow PHP and MySQL development on MacOS. stack was installed on a Macbook - OSX Yosemite v10.10.5. (I've worked with WAMP on Windows 10 with similar results.

  2. Create Directory Structure

    In the Document Root of the MAMPPersonal webserver stack to allow PHP and MySQL development on MacOS. install, the following directory structure was created.


    For MAMPS, the Document Root defaults to the htdocs directory e.g. /Applications/MAMPPersonal webserver stack to allow PHP and MySQL development on MacOS./htdocs. For other environments this directory may be www. PHPInfo can be used to find the location.

  3. Modify PHPServer-side scripting language for web development. Configuration

    Modify php.ini file to turn on errors error reporting. Default location in MAMPPersonal webserver stack to allow PHP and MySQL development on MacOS.: /Applications/MAMPPersonal webserver stack to allow PHP and MySQL development on MacOS./bin/php/php7.1.0/conf/php.ini

    display_errors = On

  4. Modify Apache Configuration File

    In the Apache configuration file - httpd.conf (Default MAMPPersonal webserver stack to allow PHP and MySQL development on MacOS. location: /Applications/MAMPPersonal webserver stack to allow PHP and MySQL development on MacOS./conf/apache/httpd.conf):

  5. Install ComposerUsed to manage the installation of third-party PHP libraries.

    Install ComposerUsed to manage the installation of third-party PHP libraries. to manage application dependencies and installations. It is available at getcomposer.org.For this project the command-line install option was used

    Additionally the following commands were run to make ComposerUsed to manage the installation of third-party PHP libraries. globally available:

    sudo mkdir /usr/local/bin
    sudo mv composer.phar /usr/local/bin/composer
    composer about

  6. Install TwigPHP template engine that simplifies the generation of HTML pages.

    Use ComposerUsed to manage the installation of third-party PHP libraries. to install TwigPHP template engine that simplifies the generation of HTML pages., which is a PHPServer-side scripting language for web development. template engine that simplifies the creation of php and html view files. In a terminal window run:

    composer require “twig/twig:~1.0”

  7. Create Database

    Create MySQLRelational database used to hold website content and search data. database TBD with the below tables:

    • LKP_CONTENT_TYPE - Table listing the different types of content (e.g. projects, posts, etc.
    • FACT_CONTENT - Table with the actual content text.
    • GUEST - User that will be used by the application to access the database. This user should be granted select on the two tables above.
  8. Create Front Controller Classes

    The website has a single point of entry index.php and uses a Router class to direct request to the appropriate classes:

    • public/.htaccess - Apache configuration file set to rewrite incoming request to go to the public index.php file, passing the original request as a query string.
    • public/index.php - Entry point for all requests. It is responsible for calling the Router and passing it the query string.
    • Core/Router.php- The Router converts the given query string into a call to the appropriate (application) Controller class method.
  9. Create (Application) Controller Classes

    The controller classes interact with the model and view classes and manage the behavior of the site:

    • Core/Controller.php - is an abstract class of which all application controllers are subclasses.
    • App/Controllers/Home.php - controls the behavior of the home page.
    • App/Controllers/Posts.php - controls the behavior of the journal pages.
    • App/Controllers/Projects.php - controls the behavior of the project pages.
  10. Create Model Classes

    Model classes interact with the database and supply data to the controllers:

    • Core/Model.php - is an abstract class from which all application model classes are a subclass.
    • App/Models/Content.php - pulls page content from database to supply to the views.
  11. Create View Classes and Pages

    • Core/View.php - View class responsible for rendering view request using the TwigPHP template engine that simplifies the generation of HTML pages. template engine.
    • App/Views/base.html - Base TwigPHP template engine that simplifies the generation of HTML pages. template that contains elements common to all views such as the navigation bar from which all view html pages inherit.
    • App/Views/Home/index.html - Home page.
    • App/Views/Posts/index.html - Journal index page with list of all posts.
    • App/Views/Posts/show.html - Shows the single journal entry selected by the user.
    • App/Views/Projects/index.html - Project index page with list of all projects.
    • App/Views/Projects/show.html - Shows the details of the single project selected by the user.
    • App/Views/Errors/404.html - Shows a more user-friendly message if a requested page cannot be found.
    • App/Views/Errors/500.html - Shows a more user-friendly message for all other errors not caused by the requested page not being found.
  12. Setup and Initialize GitCommand line tool for keeping track of changes in source files. Repository

    Since I had XCode installed GitCommand line tool for keeping track of changes in source files. was already installed on my Macbook.