Tutorial application for PHP users' group
- Hello, World
- String Literal
- Variable
- with Concat
{ }in string"vs.'
- Arrays
- Numeric 0 index
- Associative (hash table)
- Direct access
- foreach loop
- Acquire name from HTTP
- URL with
$_GET- Form
- Conditionals
$_POST$_REQUEST
- URL with
- Functions
getNameFromUrl()
- HTML
- Simple HTML
<?php<?=?>foreachin template syntax- HTML Form
- Form using
$_POST - Presets using
$_GET
- Form using
- Injection examples
- URL manipulation
- anchor in anchor
- PHP
filter_*functions htmlspecialchars()is not sufficient
- PSR-4 and Namespaces
- Directory to Namespace mapping
- composer vendor directory
- composer.json
psr-4key andsrc/directoryrequireandrequire-dev
- Auto loading and
dump-autoloadclassrequirement- static method for
handleName()
- Separation of Concerns
- View and logic separation
- Move HTTP related function to proper namespace/directory
- Domain vs. protocol
- Database Schema
- phpMyAdmin
- SQL
- PHP Data Objects (PDO)
- DSN (Data Source Name)
- protocol (mysql: or sqlite:)
- host (host=localhost)
- database name (dbname=idk)
- Exceptions
- try/catch
getMessage()- Security implications
fetchAllvs. looping withfetchprepareandexecute- Fetch Types
PDO::FETCH_ASSOCPDO::FETCH_OBJPDO::FETCH_CLASS
- Params in prepared statements
- DSN (Data Source Name)
- Refactor
- Configuration options
- Pure PHP file
- YAML, ini, JSON
- Library (DotEnv)
- Security implications
- Code repository
- Example file
- Practical Classes
- Connection Class
staticfactory method (make())- Depends on
Configclass instance - Add
PDO::ERROR_EXCEPTION
- Models
- Shared base class
- Connection as a dependency
- Add
singletontoConnection
- Connection Class
- Configuration options
- Login
- PHP Sessions
- Cookies
- File storage on server
- Token
session_*- Session variables
- Security implications
- Canary values
- CSRF
- Form
- CSRF
https/TLS- Persisting values
- Checking with
$_POST - Injection implications
- Checking with
- PHP Sessions
- Routing
- Require a file based on path returned by a function/method
- Controllers