Table of Contents for
PHP 7: Real World Application Development
Close
Version ebook
/
Retour
PHP 7: Real World Application Development
by Branko Ajzele
Published by Packt Publishing, 2016
Cover
Table of Contents
PHP 7: Real World Application Development
PHP 7: Real World Application Development
PHP 7: Real World Application Development
Credits
Preface
What you need for this learning path
Who this learning path is for
Reader feedback
Customer support
1. Module 1
1. Building a Foundation
PHP 7 installation considerations
Using the built-in PHP web server
Defining a test MySQL database
Installing PHPUnit
Implementing class autoloading
Hoovering a website
Building a deep web scanner
Creating a PHP 5 to PHP 7 code converter
2. Using PHP 7 High Performance Features
Understanding the abstract syntax tree
Understanding differences in parsing
Understanding differences in foreach() handling
Improving performance using PHP 7 enhancements
Iterating through a massive file
Uploading a spreadsheet into a database
Recursive directory iterator
3. Working with PHP Functions
Developing functions
Hinting at data types
Using return value data typing
Using iterators
Writing your own iterator using generators
4. Working with PHP Object-Oriented Programming
Developing classes
Extending classes
Using static properties and methods
Using namespaces
Defining visibility
Using interfaces
Using traits
Implementing anonymous classes
5. Interacting with a Database
Using PDO to connect to a database
Building an OOP SQL query builder
Handling pagination
Defining entities to match database tables
Tying entity classes to RDBMS queries
Embedding secondary lookups into query results
Implementing jQuery DataTables PHP lookups
6. Building Scalable Websites
Creating a generic form element generator
Creating an HTML radio element generator
Creating an HTML select element generator
Implementing a form factory
Chaining $_POST filters
Chaining $_POST validators
Tying validation to a form
7. Accessing Web Services
Converting between PHP and XML
Creating a simple REST client
Creating a simple REST server
Creating a simple SOAP client
Creating a simple SOAP server
8. Working with Date/Time and International Aspects
Using emoticons or emoji in a view script
Converting complex characters
Getting the locale from browser data
Formatting numbers by locale
Handling currency by locale
Formatting date/time by locale
Creating an HTML international calendar generator
Building a recurring events generator
Handling translation without gettext
9. Developing Middleware
Authenticating with middleware
Using middleware to implement access control
Improving performance using the cache
Implementing routing
Making inter-framework system calls
Using middleware to cross languages
10. Looking at Advanced Algorithms
Using getters and setters
Implementing a linked list
Building a bubble sort
Implementing a stack
Building a binary search class
Implementing a search engine
Displaying a multi-dimensional array and accumulating totals
11. Implementing Software Design Patterns
Creating an array to object hydrator
Building an object to array hydrator
Implementing a strategy pattern
Defining a mapper
Implementing object-relational mapping
Implementing the Pub/Sub design pattern
12. Improving Web Security
Filtering $_POST data
Validating $_POST data
Safeguarding the PHP session
Securing forms with a token
Building a secure password generator
Safeguarding forms with a CAPTCHA
Encrypting/decrypting without mcrypt
13. Best Practices, Testing, and Debugging
Using Traits and Interfaces
Universal exception handler
Universal error handler
Writing a simple test
Writing a test suite
Generating fake test data
Customizing sessions using session_start parameters
A. Defining PSR-7 Classes
Implementing PSR-7 value object classes
Developing a PSR-7 Request class
Defining a PSR-7 Response class
2. Module 2
1. Setting Up the Environment
Setting up Debian or Ubuntu
Setting up CentOS
Setting up Vagrant
Summary
2. New Features in PHP 7
New operators
Uniform variable syntax
Miscellaneous features and changes
Summary
3. Improving PHP 7 Application Performance
HTTP server optimization
HTTP persistent connection
Content Delivery Network (CDN)
CSS and JavaScript optimization
Full page caching
Varnish
The infrastructure
Summary
4. Improving Database Performance
Storage engines
The Percona Server - a fork of MySQL
MySQL performance monitoring tools
Percona XtraDB Cluster (PXC)
Redis – the key-value cache store
Memcached key-value cache store
Summary
5. Debugging and Profiling
Profiling with Xdebug
PHP DebugBar
Summary
6. Stress/Load Testing PHP Applications
ApacheBench (ab)
Siege
Load testing real-world applications
Summary
7. Best Practices in PHP Programming
Test-driven development (TDD)
Design patterns
Service-oriented architecture (SOA)
Being object-oriented and reusable always
PHP frameworks
Version control system (VCS) and Git
Deployment and Continuous Integration (CI)
Summary
A. Tools to Make Life Easy
Git – A version control system
Grunt watch
Summary
B. MVC and Frameworks
Laravel
Lumen
Apigility
Summary
3. Module 3
1. Ecosystem Overview
Summary
2. GoF Design Patterns
Structural patterns
Behavioral patterns
Summary
3. SOLID Design Principles
Open/closed principle
Liskov substitution principle
Interface Segregation Principle
Dependency inversion principle
Summary
4. Requirement Specification for a Modular Web Shop App
Wireframing
Defining a technology stack
Summary
5. Symfony at a Glance
Creating a blank project
Using Symfony console
Controller
Routing
Templates
Forms
Configuring Symfony
The bundle system
Databases and Doctrine
Testing
Validation
Summary
6. Building the Core Module
Dependencies
Implementation
Unit testing
Functional testing
Summary
7. Building the Catalog Module
Dependencies
Implementation
Unit testing
Functional testing
Summary
8. Building the Customer Module
Dependencies
Implementation
Unit testing
Functional testing
Summary
9. Building the Payment Module
Dependencies
Implementation
Unit testing
Functional testing
Summary
10. Building the Shipment Module
Dependencies
Implementation
Unit testing
Functional testing
Summary
11. Building the Sales Module
Dependencies
Implementation
Unit testing
Functional testing
Summary
12. Integrating and Distributing Modules
Understanding GitHub
Understanding Composer
Understanding Packagist
Summary
Bibliography
Index
Prev
Previous Chapter
Cover
Next
Next Chapter
PHP 7: Real World Application Development
Table of Contents
PHP 7: Real World Application Development
PHP 7: Real World Application Development
Credits
Preface
What this learning path covers
What you need for this learning path
Who this learning path is for
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Module 1
1. Building a Foundation
Introduction
PHP 7 installation considerations
How to do it...
Installing directly from source
Installing PHP 7 from pre-compiled binaries
Installing a *AMP package
There's more...
See also
Using the built-in PHP web server
How to do it...
Defining a test MySQL database
How to do it...
Installing PHPUnit
Implementing class autoloading
Getting ready
How to do it...
How it works...
Hoovering a website
How to do it...
How it works...
See also
Building a deep web scanner
How to do it...
How it works...
See also
Creating a PHP 5 to PHP 7 code converter
Getting ready
How to do it...
How it works...
See also
2. Using PHP 7 High Performance Features
Introduction
Understanding the abstract syntax tree
How to do it...
How it works...
See also
Understanding differences in parsing
How to do it...
How it works...
See also
Understanding differences in foreach() handling
How to do it...
How it works...
See also
Improving performance using PHP 7 enhancements
How to do it...
How it works...
There's more...
Iterating through a massive file
How to do it...
How it works...
Uploading a spreadsheet into a database
Getting ready...
How to do it...
How it works...
Recursive directory iterator
How to do it...
How it works...
3. Working with PHP Functions
Introduction
Developing functions
How to do it...
How it works...
Hinting at data types
How to do it...
How it works...
See also
Using return value data typing
How to do it...
How it works...
There's more...
See also
Using iterators
How to do it...
How it works...
Writing your own iterator using generators
How to do it...
How it works...
4. Working with PHP Object-Oriented Programming
Introduction
Developing classes
How to do it...
How it works...
See also...
Extending classes
How to do it...
How it works...
Using static properties and methods
How to do it...
How it works...
See also
Using namespaces
How to do it...
How it works...
Defining visibility
How to do it...
How it works...
See also
Using interfaces
How to do it...
How it works...
Using traits
How to do it...
How it works...
Implementing anonymous classes
How to do it...
How it works...
5. Interacting with a Database
Introduction
Using PDO to connect to a database
How to do it...
How it works...
See also
Building an OOP SQL query builder
How to do it...
How it works...
See also
Handling pagination
How to do it...
How it works...
See also
Defining entities to match database tables
How to do it...
How it works...
See also
Tying entity classes to RDBMS queries
How to do it...
How it works...
There's more...
Embedding secondary lookups into query results
How to do it...
How it works...
Implementing jQuery DataTables PHP lookups
How to do it...
How it works...
There's more...
6. Building Scalable Websites
Introduction
Creating a generic form element generator
How to do it...
How it works...
Creating an HTML radio element generator
How to do it...
How it works...
There's more...
Creating an HTML select element generator
How to do it...
How it works...
Implementing a form factory
How to do it...
How it works...
Chaining $_POST filters
How to do it...
How it works...
There's more...
See also
Chaining $_POST validators
How to do it...
How it works...
Tying validation to a form
How to do it...
How it works...
7. Accessing Web Services
Introduction
Converting between PHP and XML
How to do it...
How it works...
Creating a simple REST client
How to do it...
Creating a streams-based REST client
Defining a cURL-based REST client
How it works...
There's more...
See also
Creating a simple REST server
How to do it...
How it works...
There's more...
Creating a simple SOAP client
How to do it...
How it works...
See also
Creating a simple SOAP server
How to do it...
How it works...
See also
8. Working with Date/Time and International Aspects
Introduction
Using emoticons or emoji in a view script
How to do it...
How it works...
See also
Converting complex characters
How to do it...
How it works...
Getting the locale from browser data
How to do it...
How it works...
See also
Formatting numbers by locale
How to do it...
How it works...
See also
Handling currency by locale
How to do it...
How it works...
See also
Formatting date/time by locale
How to do it...
How it works...
See also
Creating an HTML international calendar generator
How to do it...
Refining internationalized output
How it works...
See also
Building a recurring events generator
How to do it...
How it works...
See also
Handling translation without gettext
How to do it...
How it works...
See also
9. Developing Middleware
Introduction
Authenticating with middleware
How to do it...
How it works...
See also
Using middleware to implement access control
How to do it...
How it works...
See also
Improving performance using the cache
How to do it...
How it works...
There's more...
See also
Implementing routing
How to do it...
How it works...
See also
Making inter-framework system calls
How to do it...
How it works...
Using middleware to cross languages
How to do it...
10. Looking at Advanced Algorithms
Introduction
Using getters and setters
How to do it...
How it works...
Implementing a linked list
How to do it...
How it works...
There's more...
Building a bubble sort
How to do it...
How it works...
Implementing a stack
How to do it...
How it works...
Building a binary search class
How to do it...
How it works...
See also
Implementing a search engine
How to do it...
How it works...
Displaying a multi-dimensional array and accumulating totals
How to do it...
How it works...
11. Implementing Software Design Patterns
Introduction
Creating an array to object hydrator
How to do it...
How it works...
Building an object to array hydrator
How to do it...
How it works...
Implementing a strategy pattern
How to do it...
How it works...
Defining a mapper
How to do it...
How it works...
Implementing object-relational mapping
How to do it...
Technique #1 - pre-loading all child information
Technique #2 - embedding secondary lookups
How it works...
See also
Implementing the Pub/Sub design pattern
How to do it...
How it works...
There's more...
See also
12. Improving Web Security
Introduction
Filtering $_POST data
How to do it...
How it works...
See also
Validating $_POST data
How to do it...
How it works...
See also
Safeguarding the PHP session
How to do it...
How it works...
See also
Securing forms with a token
How to do it...
How it works...
See also
Building a secure password generator
How to do it...
How it works...
See also
Safeguarding forms with a CAPTCHA
How to do it...
Generating a text CAPTCHA
Generating an image CAPTCHA
How it works...
There's more...
See also
Encrypting/decrypting without mcrypt
How to do it...
How it works...
There's more...
See also
13. Best Practices, Testing, and Debugging
Introduction
Using Traits and Interfaces
How to do it...
How it works...
Universal exception handler
How to do it...
How it works...
See also
Universal error handler
How to do it...
How it works...
See also
Writing a simple test
How to do it...
Running simple tests
Testing database Model classes
Using mock classes
Using anonymous classes as mock objects
Using Mock Builder
How it works...
Running simple tests
Testing database model classes
Using mock classes
There's more...
See also...
Writing a test suite
How to do it...
How it works...
See also...
Generating fake test data
How to do it...
How it works...
There's more...
Customizing sessions using session_start parameters
How to do it...
How it works...
See also...
A. Defining PSR-7 Classes
Introduction
Implementing PSR-7 value object classes
Getting ready
How to do it...
How it works...
See also
Developing a PSR-7 Request class
How to do it...
How it works...
See also
Defining a PSR-7 Response class
How to do it...
How it works...
See also
2. Module 2
1. Setting Up the Environment
Setting up Windows
Setting up Debian or Ubuntu
Debian
Ubuntu
Setting up CentOS
Installing NGINX
Installing PHP 7
Installing Percona Server
Setting up Vagrant
Summary
2. New Features in PHP 7
OOP features
Type hints
Scalar type hints
Return type hints
Namespaces and group use declaration
Non mixed group use declarations
Mixed group use declarations
The compound namespace declaration
The anonymous classes
Old-style constructor deprecation
The throwable interface
Error
New operators
The Spaceship operator (<=>)
The null coalesce operator(??)
Uniform variable syntax
Miscellaneous features and changes
Constant arrays
Multiple default cases in the switch statement
The options array for session_start function
Filtered unserialize function
Summary
3. Improving PHP 7 Application Performance
NGINX and Apache
Apache
NGINX
HTTP server optimization
Caching static files
Apache
NGINX
HTTP persistent connection
Apache
NGINX
GZIP compression
Apache
NGINX
Using PHP as a separate service
Disabling unused modules
Apache
NGINX
Web server resources
NGINX
Content Delivery Network (CDN)
Using CDN
CSS and JavaScript optimization
Merging
Minifying
Minify
Grunt
Full page caching
Varnish
The infrastructure
Web servers
The database server
Load balancer (LB)
HAProxy load balancing
HAProxy installation
HAProxy load balancing
Summary
4. Improving Database Performance
The MySQL database
Query caching
Storage engines
The MyISAM storage engine
The InnoDB storage engine
innodb_buffer_pool_size
innodb_buffer_pool_instances
innodb_log_file_size
The Percona Server - a fork of MySQL
Installing the Percona Server
MySQL performance monitoring tools
phpMyAdmin
The MySQL workbench
Percona Toolkit
pt-query-digest
pt-duplicate-key-checker
Percona XtraDB Cluster (PXC)
Redis – the key-value cache store
Connecting with the Redis server
Storing and fetching data from the Redis server
Redis management tools
Memcached key-value cache store
Summary
5. Debugging and Profiling
Xdebug
Debugging with Sublime Text
Debugging with Eclipse
Profiling with Xdebug
PHP DebugBar
Summary
6. Stress/Load Testing PHP Applications
Apache JMeter
ApacheBench (ab)
Siege
Load testing real-world applications
Magento 2
WordPress 4
Drupal 8
Summary
7. Best Practices in PHP Programming
Coding styles
Test-driven development (TDD)
Design patterns
Service-oriented architecture (SOA)
Being object-oriented and reusable always
PHP frameworks
Version control system (VCS) and Git
Deployment and Continuous Integration (CI)
Summary
A. Tools to Make Life Easy
Composer – A dependency manager for PHP
Composer installation
Using Composer
Git – A version control system
Git installation
Using Git
Creating new branches and merging
Cloning a repository
Webhooks
Desktop tools to manage repositories
Grunt watch
Summary
B. MVC and Frameworks
The MVC design pattern
Model
Views
Controllers
Laravel
Installation
Features
Routing
Eloquent ORM
Artisan CLI
Migrations
Blade templates
Other features
Lumen
Apigility
Summary
3. Module 3
1. Ecosystem Overview
Getting ready for PHP 7
Scalar type hints
Return type hints
Anonymous classes
The Closure::call() method
Generator delegation
Generator return expressions
The null coalesce operator
The Spaceship operator
Throwables
The \ParseError
Level support for the dirname() function
The integer division function
Constant arrays
Uniform variable syntax
Secure random number generator
Filtered unserialize()
Context sensitive lexer
Group use declarations
Unicode enhancements
Assertions
Changes to the list() construct
Session options
Deprecated features
Frameworks
Laravel framework
Symfony
Zend Framework
CodeIgniter
CakePHP
Slim
Yii
Phalcon
Summary
2. GoF Design Patterns
Creational patterns
Abstract factory pattern
Builder pattern
Factory method pattern
Prototype pattern
Singleton pattern
Structural patterns
Adapter pattern
Bridge pattern
Composite pattern
Decorator pattern
Facade pattern
Flyweight pattern
Proxy pattern
Behavioral patterns
Chain of responsibility pattern
Command pattern
Interpreter pattern
Iterator pattern
Mediator pattern
Memento pattern
Observer pattern
State pattern
Strategy pattern
Template pattern
Visitor pattern
Summary
3. SOLID Design Principles
Single responsibility principle
Open/closed principle
Liskov substitution principle
Interface Segregation Principle
Dependency inversion principle
Summary
4. Requirement Specification for a Modular Web Shop App
Defining application requirements
Wireframing
Defining a technology stack
The Symfony framework
Foundation framework
Summary
5. Symfony at a Glance
Installing Symfony
Creating a blank project
Using Symfony console
Controller
Routing
Templates
Forms
Configuring Symfony
The bundle system
Databases and Doctrine
Testing
Validation
Summary
6. Building the Core Module
Requirements
Dependencies
Implementation
Configuring application-wide security
Unit testing
Functional testing
Summary
7. Building the Catalog Module
Requirements
Dependencies
Implementation
Creating entities
Managing image uploads
Overriding core module services
Setting up a Category page
Setting up a Product page
Unit testing
Functional testing
Summary
8. Building the Customer Module
Requirements
Dependencies
Implementation
Creating a customer entity
Modifying the security configuration
Extending the customer entity
Creating the orders service
Creating the customer menu service
Implementing the register process
Implementing the login process
Implementing the logout process
Managing forgotten passwords
Unit testing
Functional testing
Summary
9. Building the Payment Module
Requirements
Dependencies
Implementation
Creating a card entity
Creating a card payment service
Creating a card payment controller and routes
Creating a check money payment service
Creating a check money payment controller and routes
Unit testing
Functional testing
Summary
10. Building the Shipment Module
Requirements
Dependencies
Implementation
Creating a flat rate shipment service
Creating a flat rate shipment controller and routes
Creating a dynamic rate payment service
Creating a dynamic rate shipment controller and routes
Unit testing
Functional testing
Summary
11. Building the Sales Module
Requirements
Dependencies
Implementation
Creating a Cart entity
Creating the cart item entity
Creating an Order entity
Creating a SalesOrderItem entity
Overriding the add_to_cart_url service
Overriding the checkout_menu service
Overriding the customer orders service
Overriding the bestsellers service
Creating the Cart page
Creating the Payment service
Creating the Shipment service
Creating the Checkout page
Creating the order success page
Creating a store manager dashboard
Unit testing
Functional testing
Summary
12. Integrating and Distributing Modules
Understanding Git
Understanding GitHub
Understanding Composer
Understanding Packagist
Summary
Bibliography
Index
Prev
Previous Chapter
Cover
Next
Next Chapter
PHP 7: Real World Application Development