PHP Programming: Difference between revisions
Jump to navigation
Jump to search
Lsokolowski1 (talk | contribs) |
Lsokolowski1 (talk | contribs) mNo edit summary |
||
Line 49: | Line 49: | ||
== Data Structures (refresher only) == | == Data Structures (refresher only) == | ||
* Associative arrays | * Associative arrays | ||
* Session variables, global variables, cookies | * Session variables, global variables, cookies | ||
Line 66: | Line 65: | ||
== Security == | == Security == | ||
* authorization and authentication | * authorization and authentication | ||
* using cookies and sessions | * using cookies and sessions | ||
== Dealing with Images == | == Dealing with Images == | ||
GD Library and alternatives | |||
== PHP XML == | == PHP XML == | ||
* SimpleXML | * SimpleXML | ||
* '''Expat''' Parser - event-based | * '''Expat''' Parser - event-based | ||
Line 86: | Line 83: | ||
== Object-Oriented Programming == | == Object-Oriented Programming == | ||
* Terminology Object | * Terminology Object | ||
* Declaring classes and constructors | * Declaring classes and constructors | ||
Line 96: | Line 92: | ||
* Declaring and using interfaces | * Declaring and using interfaces | ||
* exception Handling | * exception Handling | ||
* '''Examples and exercises''' | |||
** ''localhost/ws_'' | |||
** ''localhost/wordpress'' | |||
== Using Databases == | == Using Databases == | ||
* Methods of data storing | * Methods of data storing | ||
* PDO extension | * PDO extension | ||
Line 114: | Line 112: | ||
* modifying and removing data | * modifying and removing data | ||
* binding form to records in the database | * binding form to records in the database | ||
* '''Examples and exercises''' | |||
** ''localhost/phpWay'' | |||
** ''localhost/ws_'' | |||
** ''localhost/wordpress'' | |||
== Programming interfaces == | == Programming interfaces == | ||
* Architecture services | * Architecture services | ||
* Adding to the system API | * Adding to the system API | ||
Line 127: | Line 128: | ||
== Design Patterns == | == Design Patterns == | ||
* What are design patterns | * What are design patterns | ||
* Singleton Pattern | * Singleton Pattern | ||
* Factory Pattern | * Factory Pattern | ||
* MVC model-view-controller | * MVC model-view-controller | ||
* '''Examples and exercises''' | |||
** ''localhost/ws_'' | |||
** ''localhost/wordpress'' | |||
<!-- TODO: prep the OOP example with tdd, unit tests and docker; DAY2 --> | |||
== Efficiency == | == Efficiency == | ||
* Research applications performance | * Research applications performance | ||
* Code cache | * Code cache | ||
== Safety == | == Safety == | ||
* Filtering input | * Filtering input | ||
* Session fixation | * Session fixation | ||
Line 148: | Line 150: | ||
== Stacks - lamp, wamp, etc == | == Stacks - lamp, wamp, etc == | ||
* wordpress | * '''wordpress''' | ||
** https://developer.wordpress.org/advanced-administration/before-install/development/ | ** <small>https://developer.wordpress.org/advanced-administration/before-install/development/</small> | ||
* drupal | * '''drupal''' | ||
** https://www.drupal.org/docs/official_docs/local-development-guide | ** <small>https://www.drupal.org/docs/official_docs/local-development-guide</small> | ||
* symfony | * '''symfony''' | ||
** https://symfony.com/doc/current/setup.html | ** <small>https://symfony.com/doc/current/setup.html</small> | ||
* Laravel: A PHP framework known for its clean architecture and robust features, including database agnostic migrations, ORM, routing, and authentication tools. | * '''Laravel''': A PHP framework known for its clean architecture and robust features, including database agnostic migrations, ORM, routing, and authentication tools. | ||
** https://laravel.com/docs/12.x#installing-php | ** <small>https://laravel.com/docs/12.x#installing-php</small> | ||
* Zend Framework: An open-source framework for developing web applications and services using PHP. | * '''Zend Framework''': An open-source framework for developing web applications and services using PHP. | ||
** https://docs.laminas.dev/laminas-mvc/ | ** <small>https://docs.laminas.dev/laminas-mvc/</small> | ||
* CakePHP: A PHP framework that offers a robust set of tools for web application development. | <!-- | ||
* '''CakePHP''': A PHP framework that offers a robust set of tools for web application development. | |||
** todo | ** todo | ||
* PSX: A PHP framework dedicated to building fully typed REST APIs, offering a new approach to API development and challenging existing frameworks like Laravel and Symfony. | * '''PSX''': A PHP framework dedicated to building fully typed REST APIs, offering a new approach to API development and challenging existing frameworks like Laravel and Symfony. | ||
** todo | ** todo | ||
* yannoff/console: A lightweight, simple alternative to symfony/console designed for easy PHP applications development. | * '''yannoff/console''': A lightweight, simple alternative to symfony/console designed for easy PHP applications development. | ||
** todo | ** todo | ||
--> | |||
=== wp === | === wp === | ||
* wp-env | * '''wp-env''' | ||
** https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/ | ** <small>https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/</small> | ||
* ddev | * '''ddev''' | ||
** https://ddev.readthedocs.io/en/stable/users/quickstart/#wordpress | ** <small>https://ddev.readthedocs.io/en/stable/users/quickstart/#wordpress</small> | ||
* vvv | * '''vvv''' | ||
** https://varyingvagrantvagrants.org/ | ** <small>https://varyingvagrantvagrants.org/</small> | ||
* xampp | * '''xampp''' | ||
** http://apachefriends.org/ | ** <small>http://apachefriends.org/</small> | ||
* mamp | * '''mamp''' | ||
** https://documentation.mamp.info/en/MAMP-Windows/index.html | ** <small>https://documentation.mamp.info/en/MAMP-Windows/index.html</small> | ||
* local | * '''local''' | ||
** https://localwp.com/ | ** <small>https://localwp.com/</small> | ||
=== wp con't === | === wp con't === | ||
wp | wp '''API''' refs | ||
* https://developer.wordpress.org/reference/ | * <small>https://developer.wordpress.org/reference/</small> |
Revision as of 08:28, 17 March 2025
THIS IS A DRAFT
This text may not be complete.
PHP Programming Training Materials
IMPORTANT NOTE for trainers only: Please DO NOT change these materials, especially the EXERCISES, without direct permission from: LUKASZ SOKOLOWSKI.
Copyright Notice
Copyright © 2004-2025 by NobleProg Limited All rights reserved.
This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise.
Intro
PHP
- general-purpose scripting language
- especially suited to web development
- fast, flexible and pragmatic
- powers everything from simple blog to the corporate organisations
Intro con't
PHP - recursive acronym for PHP: Hypertext Preprocessor
- widely-used open source language
- can be embedded into HTML
- code is executed on the server, generating HTML which is then sent to the client
- extremely simple, yet offers many advanced features
PHP can
- collect form data
- generate dynamic page content
- send and receive cookies
- so in general - server-side scripting
- whats needed? - the PHP parser (CGI or server module), a web server, and a web browser
- be used on all major operating systems
- support most of the web servers (Apache, IIS, lighttpd, nginx, etc)
- support talking to other services - LDAP, IMAP, SNMP, NNTP, POP3, HTTP, COM (on Windows)
- work as either a module, or as a CGI processor
- do procedural programming or object-oriented programming (OOP), or a mixture of them both
PHP can con't
- also do command line scripting
- run without any server or browser - only the PHP parser is needed
- ideal for scripts regularly executed using cron (on Unix or macOS) or Task Scheduler (on Windows)
- so ie. do simple/stronger text processing tasks - Perl regexps (PCRE), etc
- output HTML, images, PDF, encrypted data, emails, JSON, XML (libxml2, SimpleXML, XMLReader, XMLWriter; XDebug)
- auto generate these files, and save them in the file system, instead of printing it out, forming a server-side cache for dynamic content
- support a wide range of databases
- via db specific ext, or abstraction layers (like PDO), or ODBC, cURL, sockets (CouchDB)
- support the WDDX complex data exchange
- instantiate Java objects and use them transparently as own objects
Data Structures (refresher only)
- Associative arrays
- Session variables, global variables, cookies
- Date
- File and File Upload
- Cookies and Sessions
- Error Handling
- Exceptions Handling
- PHP Filter
- Helpers
- Examples and exercises
- localhost/phpWay
Security
- authorization and authentication
- using cookies and sessions
Dealing with Images
GD Library and alternatives
PHP XML
- SimpleXML
- Expat Parser - event-based
- XML DOM
- XML Reader
- https://www.php.net/XMLReader
- iterators helper - https://github.com/hakre/XMLReaderIterator
Examples and exercises
- localhost/ws_
Object-Oriented Programming
- Terminology Object
- Declaring classes and constructors
- Creating and Using Objects
- Properties and methods
- Inheritance
- Access modifiers
- Magic methods
- Declaring and using interfaces
- exception Handling
- Examples and exercises
- localhost/ws_
- localhost/wordpress
Using Databases
- Methods of data storing
- PDO extension
- Connecting to a database using PDO
- Operations on data
- Error Handling PDO
- Transactions
- Primary keys
- Joins
- Aggregate functions and grouping
- connect to the database
- storing passwords
- executing queries
- processing data
- modifying and removing data
- binding form to records in the database
- Examples and exercises
- localhost/phpWay
- localhost/ws_
- localhost/wordpress
Programming interfaces
- Architecture services
- Adding to the system API
- The data format JSON and XML
- RESTful Services
- Designing Web Service
Examples and exercises
- WebServices
- localhost/ws_
Design Patterns
- What are design patterns
- Singleton Pattern
- Factory Pattern
- MVC model-view-controller
- Examples and exercises
- localhost/ws_
- localhost/wordpress
Efficiency
- Research applications performance
- Code cache
Safety
- Filtering input
- Session fixation
- Session hijacking
- SQL injection
- Storing passwords
- SSL
Stacks - lamp, wamp, etc
- wordpress
- drupal
- symfony
- Laravel: A PHP framework known for its clean architecture and robust features, including database agnostic migrations, ORM, routing, and authentication tools.
- Zend Framework: An open-source framework for developing web applications and services using PHP.
wp
- wp-env
- ddev
- vvv
- xampp
- mamp
- local
wp con't
wp API refs