Environment Setup and PHP Primer

Homework

  1. XAMPP (the classic way to install Apache, PHP and MySQL/MariaDB)
  2. PHP Tutorials
  3. PHP Loops

Morning reflection

Housekeeping

  • Videos now hosted on Vimeo. Uploading will be a slow process. Let Tony know if there are any you’d like uploaded first (20GB/week upload quota).
  • CPNT 262 Assignment 5: Due date extended to Friday.
  • CPNT 262 Final Project: DM Tony a summary of your Fancy Feature in Slack. A video chat will be scheduledm if needed.
  • Poll: Do you have PHP/MySQL installed already?

1. Install XAMPP

Learning Objectives

  • Summarize the differences between the Node and PHP server environments.
  • Install XAMPP or a similar PHP/MySQL development environment.
  • Locate the local location of the PHP web directory.

Terminology

LAMP Stack
A server environment that uses Linux (operating system), Apache (web server), MySQL (database) and PHP (codebase). Wordpress runs on the LAMP stack.
Single Threaded
One process handles all requests, one command at a time. The Jacascript run-time environment is single threaded. In other languages, such as PHP, the server is multi-threaded: a new process is created for each individual server request.
Multi Threaded
A process is created for each request and is ended when the response has been sent (or not sent). The PHP run-time environment is multi threaded. There is no event queue (the way we think of it). The server will handle multiple requests at a time, although they are handled synchronously.
Synchronous
One at a time (and in order).

Materials

  • Note: If you already have php and mysql set up on your machine, you can skip this step.
  • Install XAMPP
  • XAMPP startup checklist
    • Once XAMPP is set up and you’ve located your htdocs folder, clone this repo into that folder.

Key Takeaways

  • php is ooooold, pre-dating both Javascript and CSS. Many of the patterns it uses are just as old.
  • Unlike Node, a LAMP server has one web directory where all php files need to be located. It’s usually called htdocs.
  • Installing XAMPP is pretty straight forward but finding the web directory can be tricky on Mac OS. The XAMPP startup checklist has more details.
  • Windows users:
    • A restart might be required.
    • Install in the c: directory. You might get permissions problems if you install in Program Files. See this Stackoverflow

2. Import aviano-db database

Learning Objectives

  1. Locate the phpMyAdmin control panel in XAMPP.
  2. Import a database using the phpMyAdmin control panel.
  3. Connect to a database using php and the mysqli extension.

Materials

Key Takeaways

  • Connecting to a database as the root user is risky. Instead, we’ll create a new db user with limited access permissions.
  • The goal for today is to import and make a test connection to our rentals database. We’ll talk about SQL in detail tomorrow.

3. PHP Introduction

Learning Objectives

  1. Summarize the differences in syntax between Javascript and PHP.
  2. Understand how php tags are implemented.
  3. Refactor an html website to use php partials.

Materials

Key Takeaways

  • php is not a focus of this course but some basic knowledge will help navigate mysql and Wordpress later on. Today we’ll take a look at basic syntax and examples of some simple php websites.

Open lab-time

  1. Get php and mysql running on your local machine!

Dailies

  • No Daily today beyond successfully installing php and mysql.