{"id":16839,"date":"2015-08-28T05:01:15","date_gmt":"2015-08-27T19:01:15","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=16839"},"modified":"2015-08-28T06:29:46","modified_gmt":"2015-08-27T20:29:46","slug":"php-desktop-command-line-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/php-desktop-command-line-primer-tutorial\/","title":{"rendered":"PHP Desktop Command Line Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/php_substitute_desktop.jpg\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"PHP Desktop Command Line Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/php_substitute_desktop.jpg\" title=\"PHP Desktop Command Line Primer Tutorial\"    \/><\/a><p class=\"wp-caption-text\">PHP Desktop Command Line Primer Tutorial<\/p><\/div>\n<p>Sometimes you have desktop program requirements involving files and the operating system.  If the job is quite large you&#8217;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.<\/p>\n<p>To avoid some of this bother for smaller jobs we recommend, in Windows, Digital Mars C (or D), and we&#8217;ve talked about that <a target=_blank title='Digital Mars blog posts' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=digital-mars'>here<\/a>.<\/p>\n<p>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 <a target=_blank title='PHP Modes of Use File Traverse Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/php-modes-of-use-file-traverse-tutorial\/'>PHP Modes of Use File Traverse Tutorial<\/a>?<\/p>\n<p>The job we show today is an XML Chapter Changes via the Substitution of Strings desktop job.   In this job we have &#8230;<\/p>\n<ol>\n<li>a filespec, on the desktop (or USB) of input data files<\/li>\n<li>a mapping string file (or the data of) to map the chapter information, only, that is of interest<\/li>\n<\/ol>\n<p> &#8230; from that we start with a quick MAMP web application solution &#8230; we&#8217;ll show you here as renumber_more.php_GETME full of hardcodings and assumptions.<\/p>\n<p>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 <a target=_blank title='Useful link' href='http:\/\/stackoverflow.com\/questions\/2929629\/how-do-i-write-a-command-line-interactive-php-script'>this link<\/a> (thanks).  This interactivity only happens in the PHP usage from the command line, and to test for that we &#8230;<\/p>\n<p><code><br \/>\n if (isset($argv[0])) {  \/\/ PHP command line specific interactive input code below ...<br \/>\n  \/\/<br \/>\n  \/\/ PHP command line specific interactive input code<br \/>\n  \/\/<br \/>\n }  \/\/ ... end of PHP command line specific interactive input code<br \/>\n<\/code><\/p>\n<p>Here is that PHP code &#8230;<\/p>\n<ul>\n<li><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/renumber_more.php-GETME\" title='renumber_more.php'>renumber_more.php-GETME<\/a> &#8230; for desktop prompted interactive use and\/or web application (defaults only) usage<\/li>\n<li><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/renumber_more.php_GETME\" title='renumber_more.php'>renumber_more.php_GETME<\/a> &#8230; web application (defaults only, and &#8220;hardcoded&#8221;) usage<\/li>\n<li><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/renumber_more.php-GETME\" title='renumber_more.php'>Changes<\/a><\/li>\n<\/ul>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d16839' onclick='var dv=document.getElementById(\"d16839\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/?tag=command-line\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d16839' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you have desktop program requirements involving files and the operating system. If the job is quite large you&#8217;d probably want to involve one of the well known IDEs like Xcode for Mac or Visual Studio for Windows or perhaps &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/php-desktop-command-line-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,29,33,37],"tags":[234,319,372,617,707,714,744,885,932,997,1252,1319,1402,1480],"class_list":["post-16839","post","type-post","status-publish","format-standard","hentry","category-elearning","category-operating-system","category-software","category-tutorials","tag-command-line","tag-desktop","tag-easyphp","tag-interactive","tag-linux","tag-local-web-server","tag-mamp","tag-operating-system-2","tag-php","tag-programming","tag-terminal","tag-tutorial","tag-web-application","tag-xml"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/16839"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=16839"}],"version-history":[{"count":8,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/16839\/revisions"}],"predecessor-version":[{"id":16847,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/16839\/revisions\/16847"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=16839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=16839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=16839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}