PHP Desktop Command Line Follow Up Tutorial

PHP Desktop Command Line Follow Up Tutorial

PHP Desktop Command Line Follow Up Tutorial

Yesterday we started on some PHP desktop tutorials for a XML Chapter Changes via the Substitution of Strings desktop job when we presented PHP Desktop Command Line Primer Tutorial as shown below.

Of the three web modes of use today’s improvement work is …

  • web browsing (or “surfing the net”) … we add an HTML form as pictured … that one is relatively easy
  • command line usage … we leave it as is, interactively asking the user for information … though you could approach this with a menu system perhaps
  • curl on the command line … now this is more problematic because of the difficulty with interactive input and curl usage … so we …
    1. in the first instance expect the user to type
      “curl http://www.rjmprogramming.com.au/PHP/renumber_more.php”
      at the command line to start off
    2. the user sees on the command line the output of the underlying HTML as if web browsing, but it contains a more complex
      “curl http://www.rjmprogramming.com.au/PHP/renumber_more.php?curlget=%7Cfilespec%3DCOM_.IOVBK%2F%2A.xml%7Cynftt%3D%23%40%21%40%23%7Cprefix1%3Dolink%3E%7Cprefix2%3Dolink+targetptr%3D%22start%22%3E%7Cprefix3%3Dolink+targetptr%3D%22end%22%3E%7Cprefix4%3Dlabel%3D%22%5B%7Cprefix5%3Dlabel%3D%22%7Cprefix6%3DCOMM.IOVBK%7ECH.%7Clookup%3D%5B30.%2C%5B29.%7C%5B32.%2C%5B30.%7C%5B33.%2C%5B31.%7C%5B34.%2C%5B32.%7C%5B35.%2C%5B33.%7C%5B36.%2C%5B34.%7C%5B37.%2C%5B35.%7C%5B38.%2C%5B36.%7C%5B39.%2C%5B37.%7C%5B40.%2C%5B38.%7C%5B41.%2C%5B39.%7C%5B42.%2C%5B40.%7C%5B43.%2C%5B41.%7C%5B46.%2C%5B42.%7C%5B47.%2C%5B43.%7C%5B48.%2C%5B44.%7C%5B49.%2C%5B45.%7C%5B50.%2C%5B46.%7C%5B50A.%2C%5B47.%7C%5B52.%2C%5B48.%7C%5B53.%2C%5B49.%7C%5B54.%2C%5B50.%7C%5B55.%2C%5B51.%7C%5B56.%2C%5B52.%7C%5B59.%2C%5B53.%7C%5B60.%2C%5B54.%7C%5B61.%2C%5B55.”
      type of suggestion command line idea which the user can copy and adjust (in that encoded way, unfortunately, using vertical bar | as the major delimiter) into another copy buffer
    3. the user pastes that adjusted new complex curl command onto the command line, to complete the task

All in all, we do not recommend curl usage, for this job!

Here is that PHP code …


Previous relevant PHP Desktop Command Line Primer Tutorial is shown below.

PHP Desktop Command Line Primer Tutorial

PHP Desktop Command Line Primer Tutorial

Sometimes you have desktop program requirements involving files and the operating system. If the job is quite large you’d probably want to involve one of the well known IDEs like Xcode for Mac or Visual Studio for Windows or perhaps NetBeans or Code:Block and they could provide solutions in a whole gamut of compilable programming languages such as C++, C#, VB.Net, C or Java, just to name a few.

To avoid some of this bother for smaller jobs we recommend, in Windows, Digital Mars C (or D), and we’ve talked about that here.

Today we start on a short journey to show you that PHP at the command line, with command line curl, or as a web application (especially with a local MAMP web server on Mac or EasyPHP web server on Windows) can be another option. Do you remember PHP Modes of Use File Traverse Tutorial?

The job we show today is an XML Chapter Changes via the Substitution of Strings desktop job. In this job we have …

  1. a filespec, on the desktop (or USB) of input data files
  2. a mapping string file (or the data of) to map the chapter information, only, that is of interest

… from that we start with a quick MAMP web application solution … we’ll show you here as renumber_more.php_GETME full of hardcodings and assumptions.

We rid the code of many hardcodings to genericize it considerably, and we show you some of that journey via renumber_more.php-GETME where we introduced some PHP command line interactive usage where we got help from this link (thanks). This interactivity only happens in the PHP usage from the command line, and to test for that we …


if (isset($argv[0])) { // PHP command line specific interactive input code below ...
//
// PHP command line specific interactive input code
//
} // ... end of PHP command line specific interactive input code

Here is that PHP code …

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Operating System, Software, Tutorials and tagged , , , , , , , , , , , , , , . Bookmark the permalink.

6 Responses to PHP Desktop Command Line Follow Up Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *