3. Zwamp server development ibrowser menu

HOME     2.April.2016 see https://github.com/slavkoss/fwphp
to download learning php code for :

Own php MVC framework (main menu) skeleton primary for learnig or using in applications.

Tested on: Windows 10 64 bit PHP 5.5.30 (min. 5.4), portable ZWAMP server menu SW (I briefly tried 4-5 others but ZWAMP with unpacking ZIPs & little config works best for me !! Others portable are “portable”.

Newest WAMP 3.0.4 seems excellent but I do not know how to use Composer with it. XAMPP is also not clear enough to me. (Same as others).

fwphp properties:

  1. newest php programming techniques, excellent learning start for Laravel, Falcon, yii2, codeigniter…
    or some micro php fw but also to build upon own main menus.
  2. MVC code organization
  3. classes grouped into namespaces with autoloading (on demand loading)
  4. advanced router with pretty URLs (Apache mod_rewrite)
  5. keys in routing tbl are regular expressions not strings
    Comming soon :
  6. controllers (programs that decide the response they are going to return as views to users)
    with action filters (useful for authentication) – partially finished
    Planned :
  7. views (presentation code) including template Twig engine (easier views coding)
  8. models (data handling code, DBInterface code) with on-demand DB connecting (resoutce friendly database connectivity)
  9. possible environment switchings (environment specific config & error handling)

All my learning/testing php code :
my blog http://phporacle.altervista.org/
or github https://github.com/slavkoss/fwphp/

2.Sept.2015 Download – see site_ver2.rar from my article 9. Here is important lsweb.php – excellent for development (and very simple once you understand it).

zwamp.rar – this is old code, use it only to see how to work with static class elements. Folder names in .rar are simmilar to my development site folder names. (All is tested with  ~newest 64 bit SW). Contains scripts to learn higher level begining PHP :

  1. Apache & php config scripts
  2. zwamp scripts – main development menu
  3. ls scripts – web server dirs navigation
  4. yiiinfo scripts

Goal is basic web development site. Best way to learn is start with small portion of code and add few lines step by step.

May 2015  Code refactored 3 :  Not finished yet, later I shall write new article “Web development and production site (virtual hosts, aliases) on Windows 8.1 , Oracle 11gXE (and 11g), PHP (all 64 bit) on hard disk and on Usb stick“. Code refactoring 3 consists of:

  1. simplify config class with static variables
  2. simplify ls scripts for web server dirs navigation
  3. simplify DBI – I tested PDOOCI DBI (Eustáquio Rangel http://github.com/taq/pdooci) –works.  I think PDOOCI is usefull becouse it is PDO code sintax layer on OCI8 DBI code layer. One day, when PHP PDO will no more be experimental PDOOCI will not be needed.
    Eustáquio made also PHPreports (also on Github)

April. 2015 Code refactored 2 :

  1. config file defines constants and contains config class with static variables (visible in all scripts, can be changed). This is last large refactoting.
  2. Added top menu – I suppose best and simplest.
  3. explanations in this page for now are not updated but code is in .rar at top of this page.
  4. Now this scripts are : OOP, SPA, MVC domain-style, PHP outside web doc root, (paths & URLs) set up with constants and static class variables.

Feb. 2015 Code refactored 1 – php outside web doc root:
Intro explanations for now not updated. Now this scripts are :
OOP, SPA, MVC domain-style, PHP outside web doc root.

10 scripts – It is not easy – same as yii2 requirements scripts. Both examples are excellent for learning PHP.

  1. Installing Apache, PHP, Oracle 11XE (all 64 bit)
  2. 11g XE on Win 8.1.1, both 64bit – APEX VERSION 4.2.5,  Maj 24, 2014
  3. Zwamp server development ibrowser menu – all on Win 8.1.1, 64bi
  4. How to recognize mobile device – oop, spa, mvc domain-style, php outside web doc root

zwamp_taskbartray_iconzwamp<– Z_WAMP right click menu – Right click on house icon first left in the bottom

~~~~~~~~~~~
Page with blue Z: icon is output of view script view_3cols_list.php

http://zwamp.sourceforge.net/
http://sourceforge.net/projects/zwamp/files – operating system (32-bit/i386 or 64-bit/x86_64).


MVC scripts which create this home page (ee bits 1-4 on picture above).

SPA = Single Page web Application
DOMAIN STYLE CODE structure = app. (form) scripts are in ONE subdir (and its subdirs), and index.php, if needed, is in dir above this ONE application directory.

Eg – this DEVELOPMENT MAIN MENU SCRIPTS are in zwamp dir,
– Controller script: zwamp.php and all other .php, .css, .jpg… can be in same dir. (no subdirs becouse it is small app.).

ZWAMP has no such home page, I made it from WAMPs home page, with many changes :

  1. SPA was excellent
  2. DOMAIN STYLE CODE was not implemented – everything was in appl. root dir, I had problems showing pictures (eg $imgwrench = “background: …)…
  3. MVC not clear I had work on it…

bit 1.Alati (tools), eg link instalirano

  1. view_3cols_list.php - View main body: lin.14: 
    $fleview_instalir = str_replace('zwamp.php',
    'view_instalirano_20150106.html',$flezwamp); 
    ...MENU BIT CODE lin. 36 : 
    <a style="${imgwrench}" target="_blank" href="?instalirano=1">
    instalirano/a> 
    ...CODE AT THIS PAGE BOTTOM lin 144: 
    $fleview_instalirano - Installed on my PC kod edit 
    kod_edit_run($mdpath.$rel_apldir_adr, basename($fleview_instalir));
  2. zwamp.php - Controller: if (isset($_GET['instalirano'])) {include(  
    $mdpath.$rel_apldir_adr.'/view_instalirano_20150106.html' ); exit()

Menu “2.Programi (projekti)” is list of dirs ($projectContents) not in array $projectsListIgnore

  1. zwamp_conf.php – Configuration
    1. is model script for dirs list (better not but this is simple example)
    2. and stores label “2.Programi (projekti” in array $txtlang (see script code)
    $txtlang array contains texts for more languages.

    1. Model: dirs list model code in zwamp.conf:
    $projectContents = ''; if ($idmape = opendir($mdpath)) 
    { while (false !== ($mapa = readdir($idmape)))
    { //if ($mapa != "." && $mapa != "..") 
    { if (is_dir($mdpath."/".$mapa) === true 
         && !in_array($mapa,$projectsListIgnore) ) 
    { //echo "DIRECTORY: ".$mapa.'<br />'; 
       $projectContents .= '<li>' 
      .'<a style="'.$imgdirgo.'" target="_blank" href="' 
    .( $suppress_localhost ? 'http://dev:8083/inc/fw/' : '' ) 
    .$mapa.'">'.$mapa .'</a>' .'</li>'; } else { 
    //echo "FILE: ".$mapa.'<br />'; } } closedir($idmape); }
    if (empty($projectContents)) $projectContents = 
    "<li>".$txtlang[$jezik]['txtNoProjet']."</li>\n";
  2. view_3cols_list.php – View main displays array $projectContents :
    <ul class="projects">
        ${projectContents}
    </ul>

Menu “3.Aliasi i virt.hostovi” is list of files ($aliasContents)

  1. zwamp_conf.php – Configuration (Aliases are .conf files in dir “alias” below Z:.)
    1. is model script for files list (better not but this is simple example)
    2. and stores label “3.Aliasi i virt.hostovi” in array $txtlang (see script code)
    $txtlang array contains texts for more languages.

    1. Model: files list model code in zwamp.conf:  
    $aliasContents = '';
    // ucitavanje liste (récupération) alias-a
    if ($idmape = opendir($aliasDir))
    {
    while (false !== ($konfig_file = readdir($idmape)))
    { if (!is_dir($aliasDir.$konfig_file) 
        && strstr($konfig_file, '.conf'))
    { //echo "DIRECTORY: ".$konfig_file.'<br />';
    $alias_ime = str_replace('.conf','',$konfig_file);
    $urlbit = $alias_ime;
    if ($alias_ime == 'dev') { // http://dev/
    // apache sada nece dodati localhost/ ispred dev :
    $urlbit = 'http://'.$alias_ime ;
    $alias_ime = $alias_ime . ' (vhost)';
    } else // svi ostali aliasi su kao adminer ispod .sys :
    { // /.sys/adminer tj http://localhost/adminer/
       $urlbit = 'http://dev/'.$alias_ime ;
    } ;
    $aliasContents .=
    '<li>'.'<a style="'.$imgdir.'"'
    . ' href="'.$urlbit.'">'.$alias_ime.'</a>'.'</li>';
    }
    }
    closedir($idmape);
    } else {
    //echo "FILE: ".$konfig_file.'<br />';
    }
    if (empty($aliasContents))
       $aliasContents = "<li>" . $txtlang[$jezik]['txtNoAlias']."</li>\n";
    else $aliasContents = 'Aliasi su .conf u mapi "alias" ispod Z:.'
        .'<br />'.'Služe za aplik. u mapi "apps" ispod Z:.'
        .$aliasContents;
  2. view_3cols_list.php – View main displays array $aliasContents :
    <ul class="aliases">
        ${aliasContents}
    </ul>
    

List “4.Server configuration” is list of PHP extensions ($loaded_extensions)

  1. zwamp_conf.php – Configuration
    1. is model script PHP extensions (better not but this is simple example)
    2. and stores label “3.Aliasi i virt.hostovi” in array $txtlang (see script code)
    $txtlang array contains texts for more languages.

    1. Model: PHP exstensions list model code in zwamp.conf:  
    $phpExtContents = '';
    // read liste des PHP extensions
    $loaded_extensions = get_loaded_extensions();
    // [modif oto] classement alphabétique des extensions
    setlocale(LC_ALL,"{$txtlang[$jezik]['locale']}");
    sort($loaded_extensions,SORT_LOCALE_STRING);
    foreach ($loaded_extensions as $extension)
    $phpExtContents .=
    "<li style=\"${imgplugin};\">${extension}</li>;

    view_3cols_list.php – View main displays array $phpExtContents :

    <dd><ul>${phpExtContents}</ul></dd>

 

II. Notepad Replacer – handy for taskbartrayicon-rightclickmenu, but Notepad++ workspaces, projects and sessions are enough.

http://www.binaryfortress.com/NotepadReplacer/Discussions/View/wont-install-properly-on-win2008-sp2-x64/?ID=04b032d7-ba27-49cf-b6cd-5057ec4a7b8e
Replace Microsoft Notepad with Notepad++ (windows 8) :

Regedit node created with NotepadReplacerSetup-1.1.6.exe :

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe.

string (REG_SZ) name “Debugger”
value “C:\Program Files (x86)\Notepad Replacer\NotepadReplacer.exe” /z –BEZ ” i BEZ /z

which opens J:\aplp\aplp\3_edit\3_Notepad++\notepad++.exe

III.  SCRIPTS CODE (REFACTORED Feb, 2015)

  1. C:\Windows\system32\drivers\etc\hosts

    127.0.0.1       localhost
    ::1             localhost
    127.0.0.1     dev
    ::1     dev

  2. J:\zwamp\vdrive\.sys\Apache2\conf\httpd.conf

    or   Z:\.sys\Apache2\conf\httpd.conf

  3. J:\zwamp\vdrive\.sys\Apache2\conf\vhosts.conf

    or Z:\.sys\Apache2\conf\vhosts.conf

    # ZWAMP does:   (subst Z: “J:\zwamp\vdrive”)

    # http://dev:8083/
    <VirtualHost *:8083>
    Options All
    #Options +Includes +FollowSymLinks +Indexes +MultiViews
    #+ExecCGI
    DocumentRoot “J:\dev_web\htdocs
    ServerName dev
    </VirtualHost># http://yii:8083/   – not available when listening port 8083 !?
    <VirtualHost *:8083>
    DocumentRoot “J:\dev_web\htdocs\aplyii\frontend\web
    ServerName yii
    </VirtualHost>

    # ———————————
    # http://localhost:8083/
    <VirtualHost *:8083>
    DocumentRoot “J:\zwamp\vdrive\web
    ServerName localhost
    </VirtualHost>

  4. J:\zwamp\vdrive\.sys\php\php.ini

     

    —–

  5. J:\dev_web\htdocs\index.php

    (if needed). Includes zwamp scripts – which all are outside Apache doc.root  J:\dev_web\htdocs (http://dev:8083/):require(realpath($_SERVER[‘DOCUMENT_ROOT’].’/../inc/zwamp/zwamp.php’)) ;
    exit;

  6. J:\dev_web\inc\zwamp\zwamp.php

    – Controller outside Apache doc.root  (was : J:\dev_web\htdocs\01programi\zwamp\zwamp.php)
    ….
    ************************************************************
    // 3. SHOW VIEW BITS – ee THIS SPA WEB PAGE – Single Page App.
    // ************************************************************
    echo <<< EOPG
    $pghdr
    $view_3cols_list
    <br /><br />
    $view_nppreplacer
    $view_zwamp
    $view_hosts_apachephpconf
    <br /><hr />
    $view_mongodb
    $view_f3fw
    $view_phpreports
    EOPG;/**
    * http://dev:8083/ = Apache virt.host
    *           or zwamp docroot: http://localhost/
    * J:\dev_web\inc\zwamp\zwamp.php
    *           or J:\zwamp\vdrive\web\index.php
    *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    *               ~~~ C O N T R O L L E R ~~~
    * SPA web page (Single Page App.) – no url calls
    * DOMAIN STYLE code organization – every app (page, oracle form form) own subdir
    *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    *SHOWS VIEWS: main menu (1,2,3):
    *             1.Alati (tools & help)
    *             2.Programs (projects, dirs)
    *             3.Aliases & virt.hosts
    *             4.List below (php extensions)
    *             … some help texts
    * No DBI – CRUD scripts (could be sqlite for langs).
    *        – No page params of  p o s t  type – no forms
    *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    *
    ****************************************************
    * 1. PAGE PARAMS OF G E T TYPE (ACTION COMMANDS)
    ****************************************************
    * 1.1 Display image code (from zwamp_mdl.php)
    * 1.2 Language icons in page hdr top right
    * 1.3a PAGE NAVIGATION: PATH C A L L –  I N C L U D E
    * 1.3b                  URL  C A L L – Location ()
    *
    * No page params of  p o s t  type – no forms – no DBI
    * ********************************************************
    *  2. INCLUDE VIEW BITS – LOAD THEM IN CONTENT VARIJABLES
    * ********************************************************
    *
    * ********************************************************
    *  3. SHOW VIEW BITS – ee THIS SPA WEB PAGE – Single Page App.
    * ********************************************************
    *

  7. J:\dev_web\inc\zwamp\zwamp_mdl.php

    – Configuration, set up, data (img code !)
    —–

  8. J:\dev_web\inc\zwamp\zwamp_hdr.php

    – View main hdr

  9. J:\dev_web\inc\zwamp\view_3cols_list.php

    – View main body

  10. J:\dev_web\inc\zwamp\view_zwamp.php

    – View zwamp and simmilar view code bits

  11. Helpers – utils
    J:\dev_web\htdocs\inc\utl\showsource.php

    & phpinfo & edservertxt.php &

    <?php
    // J:\dev_web\inc\utl\kod_edit_run.php
    function kod_edit_run($script_dir_path, $script_name, $web_docroot_url)
    {
    $ds = DIRECTORY_SEPARATOR;
    echo <<< EOKOD
    <a href=”$web_docroot_url/inc/utl/showsource.php
    ?file=$script_dir_path$ds$script_name
    &line=1&prev=10000&next=10000
    ”  target=”_blank”>&nbsp;kod</a>

    <a href=”$web_docroot_url/inc/utl/edservertxt.php
    ?file=$script_dir_path$ds$script_name
    ” target=”_blank”>&nbsp;edit</a>

    <a href=”$web_docroot_url/phpinfo_inc.php
    ” target=”_blank”>&nbsp;phpinfo</a>
    EOKOD;
    /* call it so:
    kod_edit_run(
    $idx       // script_dir_path
    , $idxscript // script_name
    , MDURL);    // web_docroot_url = (Apache) web server URL
    */
    }