Lecture 1. PHP and the View

Recordings

Adobe Connect recording

Lecture 1. HTTP, PHP, Tools, Dev

HTTP

Pipes

http://ryanstutorials.net/linuxtutorial/piping.php

Sockets & Ports

Protocols, HTTP

HTTP Request

Taken from http://www.jmarshall.com/easy/http/


GET index.php HTTP/1.0
User-Agent: HTTPTool/1.0

HTTP Response

HTTP/1.0 200 OK
Date: Fri, 31 Dec 1999 23:59:59 GM
Content-Length: 14
Content-Type: Text/HTML

<html></html>

Example Telnet

telnet csquiz.lnu.se 81

Cookies, header, session cookie

Example (index.php)

http://www.phptherightway.com/

Vagrant, Sublime,

http://localhost:8085/index.php

PHP as a language

PHP is an interpreted script language.

It is hated and loved (and so by me)

Some of PHP features:

Some of the downsides:

  • It is weakly typed (with type hinting). (PHP7)
  • It is slow for number crunching
  • It hard to manage larger applications.

Model, View, Controller A quick intro

Why do we need an architecture?

  • map
  • design guide
  • reusable design
  • constraints that help us define solution space

https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller

  • Model Business rules (what would be the same for all use-cases)
  • Controller (Use cases, makes changes to the model depending on user input)
  • View (interface, generates what user sees)

Please note that MVC has many different interpretations and versions. (check an image search on google)

View

The views responsibilities are to translate input to higher level input and generate output.

Server(PHP) to browser

HTML, Javascript, Images, CSS, URL, setcookie-headers, status code(200 OK)

All this can be generated by PHP.

Example HTMLView

namespaces, class, private, public, constructor, member variable, parameters

Browser to server(PHP)

url, post, cookies, file-upload

Syncronous (ajax)

Session PHPSESSID


0W4tUCe3tTKe

Welcome to CoursePress

en utav Linnéuniversitets lärplattformar. Som inloggad student kan du kommunicera, hålla koll på dina kurser och mycket mer. Du som är gäst kan nå de flesta kurser och dess innehåll utan att logga in.

Läs mer lärplattformar vid Linnéuniversitetet

Student account

To log in you need a student account at Linnaeus University.

Read more about collecting your account

Log in LNU