Skip to content

Latest commit

 

History

History
184 lines (159 loc) · 7.7 KB

php-iii-jul-2018.md

File metadata and controls

184 lines (159 loc) · 7.7 KB

PHP-III CLASS NOTES -- Jul 2018

NOTE TO SELF: after importing *.json file into postman, how do you run those requests? NOTE TO SELF: upload to the repo example using Stragility v2

HOMEWORK

FOR FRI 27 Jul 2018

  • Middleware Lab
    • DO NOT create a new zend-expressive-skeleton app!!!
    • Use the existing code under the /expressive folder

FOR WED 25 Jul 2018

  • Apigility Lab

FOR MON 23 Jul 2018

  • OPTIONAL Extension Lab:
    • Install MongoDB on the VM
    • Install the PHP driver
  • Apache JMeter Lab
    • It's not locked to the launcher
    • Click on extreme top left search icon
    • Start typing jmeter
    • Click on the feather
  • All the Docker Labs in Chapter 6
    • To add an entry to the local hosts file
    • Find the IP address for the docker image by typing ifconfig
    • Add that to the /etc/hosts file on the VM:
sudo gedit /etc/hosts
  • Add ip address and host name of your choice
  • To confirm: ping -c3 host.name
  • Do all the Docker labs

FOR FRI 20 Jul 2018

  • Extension Custom Development Lab
  • Custom PHP Lab
  • CD Phing Build Tool Lab
  • Continuous Delivery Lab

FOR WEDS 18 Jul 2018

  • Built-in Web Server Lab

FOR MON 16 Jul 2018

  • Define an app that uses software events (or PubSub)
    • Define an EventManager class as a singleton
      • Define attach() which takes and event and a callable as arguments
        • The callable needs to accept an array of parameters
      • Define trigger() which runs the callable and passes an array of parameters
    • Define two other classes which get an instance of the EventManager
      • Have each of the other classes trigger one or more of the events
    • Create a calling program
      • Provides configuration to the EventManager and creates an instance
      • Creates instances of the other 2 classes and passes in the EventManager
      • Runs methods from the other 2 classes
  • Use Iterators to do the following:
    • Do a recursive directory scan of the /php3/* directory structure
    • Use FilterIterator to include only *.php files
    • Use LimitIterator to paginate 20 items per page
    • Use InfiniteIterator to loop back to the beginning when you hit the last page

Example of DatePeriod

  • You can use Relative Formats with DateInterval::createFromDateString ( string $time )

Q & A

public function getDimensions() {
        yield from $this->widths;
        yield from $this->lengths;
    }

NOTES

Stream

PHP 7

Data Structures

PHP CLI

  • Capture command line parameters using either $argv[] or $_SERVER['argv'][]

Cache

Custom PHP

  • The download URL varies depending on the code name for the release. The example shown in the slides is "krakjoe" which is 7.1. The upcoming version 7.3 has a codename "cmb".
  • Just click on the link shown on the main page of http://php.net/
  • Here is another example of a PHP custom installation configure command string: https://github.com/dbierer/php7_examples#manual-php-7-installation
  • You can also use php -i (from the command line) or phpinfo() (from a browser) to get the configure string used for an existing installation

RE: Thread Safe (TS) vs. Non-Thread Save (NTS) on Windows

Docker

Apigility

  • Start Up: http://apigility/ from the browser in the VM
  • http://localhost:9999/#/7/32: post actual graphic of .htaccess (hard to see)
  • http://localhost:9999/#/7/50: missing one thing to copy: the php3/src/ModWebApi/PropulsionSystems directory over into the apigility/module/FlyingElephantService/Rest
    • Look at the next slide to see what the final dir structure should look like
  • http://localhost:9999/#/7/50: missing one file: php3/src/ModWebApi/Flying Elephant Apigility.postman_collection.json
    • Posted 2 versions of the files in the repo

MiddleWare

Architecture

cd /path/to/this/repo/expressive-demo
php -S localhost:9999 -t public
  • From your browser: http://localhost:9999/
  • Click on the Strategy Test link
    • Output should be HTML
  • Open up postman or use the FireFox REST Client
    • Add this header: Accept: application/json
    • Issue a GET request
    • Output should be JSON