Skip to content

Latest commit

 

History

History
130 lines (74 loc) · 5.77 KB

README-old.md

File metadata and controls

130 lines (74 loc) · 5.77 KB

evote-movie-2022

About

This is a sequence of progressive enhancements, taking a static HTML site into an authenticated modern PHP MVC website

The website is about movies and user voted stars.

screenshot list of moives

An OO-PHP first approach

DB-drive websites in PHP are much simpler when programming in Object-Oriented PHP, so that's the approach taken here. If you've not programmed with an OO language before, you may wish to first work through the 2019 version of this case study:

https://github.com/dr-matt-smith/evote-movie-2019

Progressive enhancement

  1. Starting point

  2. Change HTML to PHP

  3. Add Front Controller PHP OO architecture

    • move all display pages into folder /templates

      • (keep) images and css in folder /public
    • create src folder (for all our class files)

    • create PHP class /src/MainController.php class with methods to display each of the page templates

    • create composer.json to define PHP namespaced Tudublin classes in /src:

    • at the terminal command line run composer dump-autoload to create a /vendor folder and containing autoloading script autoload.php

    • add root website script /public/index.php to run the autoload, create an Application object and invoke its run() method:

    • in the /templates folder change all navigation links in the HTML content to the form /?action=<PAGE>. This means that EVERY request goes through /public/incdexphp and our application's switch-statement in Application::run()

      • e.g. /?action=about for link to about page

      • e.g. /?action=sitemap for link to sitemap page

    • create class /src/Application.php with a run() method to test for value of GET variable action, create a $mainController object, and invoke the MainController method that corresponds to the value found for action in the URL

    • https://github.com/dr-matt-smith/evote-movie-2022-03-front-controller

  4. Separate header and foot page content in part-page templates that can be re-used

  5. List details from array of Movie objects

  6. Example of Codeception automated acceptance testing (simulating users clicking links and submitting forms):

  7. Single master script to run all the DB migrations and fixtures

  8. Associate Comment with logged-in user (if a user was logged-in) (one-to-one association)

  9. Movie-Category Many-to-one association

  10. Added Twig library to the project and converted page templates

  11. Twig master page template and child-page inheritance

    • move all common header and nav and footer content to /templates/_base.html.twig

    • define overridable head title Twig block in base template

    • define overridable main Twig block in base template

    • make all other template pages extend base and override main Twig block

    • NOTE: we have lost and current page nav indicator - we'll fix this soon :-)

    • https://github.com/dr-matt-smith/evote-movie-2022-05-twig-base-template-inheritance

  12. Use Twig blocks for CSS style to indicate current page indicated in nav bar CSS

  13. Gitpod (online editor - virtual Linux machine with MySQL)

  14. current attempt to get working in Github Codespaces online virtual machine (work in progress)

Steps todo ...

  • List CHEAP movies - custom SQL method in Repository class

  • Movie Charts - DB Many-to-many relationship