Recommend this page to a friend! |
Classes of Slavko Srakocic | B12 PHP FW | z_01DDL_and_other/readme_thoughts.md | Download |
|
Download Explanations below are difficult to understand. They are "after battle philosophy" very useful to improve basic ideas (principles). <a name="top"></a> Top.....1\.4 Dirs.....1\.3 UML.....1\.5 DM.....2\. IDE.....3\. CRUD.....SW fw CRUD module example code 7 scripts: Simplest CRUD.....index.php.....Home_ctr.....home (table page).....create.....read (user profile - form).....update....adapter 1. My PHP menu & CRUD code skeleton (I named it B12phpfw)<br><br><br> <a name="dm"></a>1\.8 DM (Domain model)Top......Dirs.....UML.....DM.....IDE.....CRUD.....SW fw UML diagram above does not show DM adapter classes. Each tbl in DB (ee each object in data source eg web servis...) has DM adapter class Tbl_crud which is pre CRUD code - calls cc, rr, uu, dd... methods like in Oracle Forms pre-query, pre-insert, pre-update... on-insert, on-update.... In Db_allsites class is eg execute-query code - only creates cursor to (loop) read row by row in view scripts or in ctr scripts). Events flow (E1) --- (E2)... - caseflow through Blog module (CRUD data skeleton)
Terms(T1) Own controller method is Mini3 PHP framework dispatching idea using home class methods (My routing using key-values is different) (T2) DM (Domain Model) are classes : 1. Tbl_crud (users table PdoAdapter) called by V script - pre CRUD (PRE-INSERT, PRE-UPDATE...) methods cc, rr, uu, dd 2. Db_allsites (AbstractDataMapper) called by Tbl_crud - same for all tables, contains CRUD (ON-INSERT, ON-UPDATE...) methods cc, rr, uu, dd (T3) DS (data source) - tbl row objects from DB or web service, or.... Only DM classes know about DS. CRUD code skeletons calls DM classes FUNCTIONALY ee WHAT ee "get invoice items", not HOW and from which DS. DS is assigned only once in config class abstract class Config_allsites extends Db_allsites (and class Home_ctr extends Config_allsites). (T4) User INTERACTIVITY (cliks link or button or types URL) requires ROUTING in C ee C (Home_ctr) is not needed for Mnu module, even for Mkd module - enough is simple controller code snippet. <br /><br /> Signals, data and code flowGraph 4 node (vrh), 7 edge (brid, border, boudary). Graph is simmilar to Euler's 4 Königsberg city parts (nodes) and 7 bridges (edges) - Chinese postman transport problem - how to Euler walk to cross each bridge (edge) only once. Traveler sailsman problem is : how to shortest walk graph to cross each city part (node) at least once and return to start node.
Picture shows M-V data flow. Model code is most complicated. C and V code can be standardized, M only partially : M in B12phpfw is DM (Domain Model) meaning eg for users table : M consists of : 1. abstract class Db_allsites which is same for all tables (cc, rr, uu, dd methods are standardized) 2. and class Tbl_crud - bussines logic in this M code can not be standardized. This M code is most complicated, it is fat (lot of code) User`s events are handled in Controller class. 1. C (class Home_ctr) assigns users orders in URL to array variables telling V what user wants (signals flow) and includes V 2. V pulls data from M data source (DB or web servis or...) (calls Tbl_crud which calls Db_allsites) according C variables (user orders in URL) 3. V links ee user orders in URL call C method which can do some state changes in M data V script may contain class but I do not see need for view classes because view script is included in Home_ctr class and can use $this to access methods and attributes in whole class hierarchy : Home_ctr, Config_allsites, Db_allsites. If we do not need CRUD than we do not need class hierarchy Home_ctr, Config_allsites, Db_allsites meaning that simple coding like in Mnu and Mkd modules suffices.. M-C-V data flow - controller instantiates M and pushes M data to V. I do not see advantages compared to M-V data flow. Disadvantage are : for pagination M-V data flow is only possible solution, M-C-V data flow makes C fat in large modules (lot of code). C in my Msg (Blog) module has lot of code, but code is very simple. So view instantiates model and pulls data from M or C instantiates model and pulls data from M. Both styles work ok, difference is important only for us - for clearer code. If we have user`s interactions (events) eg filter displayed rows (pagination is also filtering), than M-V data flow is only possible solution (M-V data flow is original MVC idea). 1\.5 Adresses on op.system and on web are difficult to understandand bad explained in all PHP frameworks and learning sources. See readme_thoughts.md
IIS wsroot_path = %SystemDrive%\\inetpub\\wwwroot = http://localhost, see Win icon -> IIS manager. For APEX learning on Oracle cloud open https://apex.oracle.com/en/ click link "Get started" and install few demo apps before making own based on eg Riaz Ahmed 2020 year "Oracle APEX 20 For Beginners" (on 18c XE DB) . <br><br><br> Package contains modules (folders) in ownWebServer_or_hosting_DOCROOT_PATH = "/". My DOCROOT_PATHs ('/') are :
Each module is in own (functional) folder like Oracle Forms someForm.fmb, Blazor and APEX pages - is best to develop more large sites. Oracle Forms authors knew this 2 dozen years ago. No M,V,C folders which, seems are mistake, delusion : putting coding technik (M,V,C code separation) in foreground instead pages (each page in own folder = module). M,V,C code separation idea is beter explained good old structured programming idea - M and V code manager = C, processing code may be M = CRUD DB table rows, output code = V. M,V,C code in one script is valid MVC coding ! Interesting is that PHP frameworks authors and learning code authors do not even mention M,V,C folders reflecting code separation in opposition (antithesis) to functional folders - modules reflecting business functions (business logic). Is it one sells what one has ee no lies, no sells ? If is, is ugly. First "/" in paths below is ownWebServer_or_hosting_DOCROOT_PATH. Modules (functional folders) are :
"fwphp" folder is one site, "glomodul" is group of shared modules reused in other modules, or testing modules or...
<br><br><br><a name="uml"></a> 1\.6 B12phpfw UML diagram - classes structure - Attributes and MethodsTop......Dirs.....UML.....DM.....IDE.....CRUD.....SW fw Adapters (implementations - classes or methods) depend on interfaces (features, ports)3-layer code skeleton (application architecture) left, center, right : "The object-oriented version of spaghetti code is, of course, lasagna code'. Too many layers." - Roberto Waltman Mar 7, 2016. HA (hexagonal architecture) is a case of application of DDD (Domain Driven Design) eg verses in OS file : | Application-managers-controllers on GUI-CLI input | BL (Business Logic) and interfaces-features-ports - processing | Adapters-implementations-tasks-dependencies and output | | :-------------------------------------------------------: | :------------------------------------------------------------- | :--------------------------------------------------------- | | OUTSIDE LEFT (User-Side) drive domain | INSIDE (core, domain, center) drive infrastructure | OUTSIDE RIGHT (infrastructure, Server-Side)| | ConsoleAdapter ---------depends on---------|---> IRequestVerses | | | |......A | | | |......l depends on | | | |......l | | | |......PoetryReader BL class ---> IObtainPoems <---depends on------|--- PoetryLibraryFileAdapter | B12phpfw simple module code skeleton (HA) eg users or post categories :| Application-managers-controllers on GUI-CLI input | BL (Business Logic) and interfaces-features-ports - processing | Adapters-implementations-tasks-dependencies and output | | :-------------------------------------------------------: | :------------------------------------------------------------- | :--------------------------------------------------------- | | OUTSIDE LEFT (User-Side) drive domain | INSIDE (core, domain, center) drive infrastructure | OUTSIDE RIGHT (infrastructure, Server-Side)| | ibrowser, Home_ctr ---depends on----------|--->methods to call/inc code Interf_Tbl_crud <---depends on-------|--- DBI: cls Tbl_crud one tbl DB adapter (repository) | | | (Interf_Home_ctr if needed !) (some BL class if needed) | DBI: trait Db_allsites : code type DB CRUD ADAPTER | Concerning business code, the inside, a good idea is to choose to organize domain modules (or directories) according to business logic. The ideal case is to be able to open a directory or a business logic module and immediately understand business problems that your program solves; rather than seeing only ?repositories?, ?services?, or other ?managers? directories or M, V, C dirs. See https://matthiasnoback.nl/2017/08/layers-ports-and-adapters-part-2-layers/ Aug 2nd 2017 by Matthias Noback. Matthias said : Simfony framework was no longer my safe haven, I worked on more basic programming topics, like SOLID and Package Design. I was fascinated by hexagonal architecture and command buses. Place for (Simfony) framework is the Infrastructure layer and you can fully embrace any kind of RAD-stupid thing your framework offers, as long as it stays inside that layer, and nothing of it trickles down into either the Application or g\*d forbid the Domain layer. You can now write alternative adapters for your application's ports. You could run an experiment with a Oracle (Mongo... or in memory) adapter side by side with a MySQL adapter. Specialized adapters for running tests is the main reason why Cockburn proposed the ports & adapters architectural style. Dependency Rule - decoupling (code separation) - Dependency Inversion Principle - "D" in SOLID( https://en.wikipedia.org/wiki/SOLID ) A practical implementation of Dependency Rule "One should depend upon abstractions, not concretions." in most object-oriented programming languages : 1. Define an interface = abstraction for the thing you want to depend on. 2. Then provide a class implementing that interface. This class contains all the low-level details that you've stripped away from the interface, hence, it's the concretion this design principle talks about. I prefer UML below : <br /><br /> <a name="directories"></a> 1\.7 B12phpfw directories (modules) structureTop.....Dirs.....UML.....DM.....IDE.....CRUD.....SW fw See info code : http://phporacle.eu5.net/fwphp/glomodul/z_examples/03_info_php_apache_config_scripts.php https://github.com/slavkoss/fwphp/blob/master/fwphp/glomodul/z_examples/03_info_php_apache_config_scripts.php B12phpfw is very diferent than (all ?) other PHP frameworks (I prefer "menu & CRUD code skeleton") because dirs are like Oracle FORMS form module .fmb and other reasons mentioned below. But basics are same : HexArch (Hexagonal architecture) application of DDD (Domain Driven Design) : example img gallery code https://github.com/oumarkonate/hexagonal-architecture 1. application directory : src/Config contains ~ code in my Config_allsites cls 2. application directory : src/Controller contains ~ code in my Config_allsites cls and Home_ctr cls 3. Domain (model) code in directory src/Domain contains ~ code in my Db_allsites cls 4. Infrastructure (or Common) dir contains dependencies that app code needs to work - my zinc dir See "What is SW fw". my DEVELOPMENT DOCROOT J:\\awww\\www ee http://dev1:8083/ OR TEST DOCROOT J:\\ylaragon\\www (was J:\\xampp\\htdocs) ee http://localhost:8083/ (http://SSPC2:8083/ ) OR PRODUCTION (DEMO) DOCROOT http://phporacle.eu5.net/ | In Windows tree /A shows :
<br /><br /> <a name="directories"></a> 1\.4 B12phpfw directories (modules) structureTop.....Dirs.....UML.....DM.....IDE.....CRUD.....SW fw <br />
<br />
<a name="dm"></a>1\.5 DM (Domain model)Top......Dirs.....UML.....DM.....IDE.....CRUD.....SW fw <br /><br /><a name="SimplestCRUD"></a> Simplest user CRUD module - 7 scripts which are in all CRUD modules (same named)SimplestCRUD.....index.php.....Home_ctr.....home (table page).....create.....read (user profile - form).....update....adapter <a name="scrudIndex"></a> 1\.5\.1 index.phpSimplest CRUD.....index.php.....Home_ctr.....home (table page).....create.....read (user profile - form).....update ....adapter
<a name="scrudHome_ctr"></a> 1\.5\.2 Home_ctr.php router, dispatcherindex.php.....index.php.....Home_ctr.....home (table page).....create.....read (user profile - form).....update....adapter
<a name="scrudHomeV"></a> 1\.5\.3 home.php - shows links assigned in Home_ctr.php for user interactionsindex.php.....index.php.....Home_ctr.....home (table page.....create.....read (user profile - form).....update....adapter
<a name="scrudC"></a> 1\.5\.4 create.phpindex.php.....index.php.....Home_ctr.....home (table page).....create.....read (user profile - form).....update....adapter
<a name="scrudR"></a> 1\.5\.5 read.php - display user profileindex.php.....index.php.....Home_ctr.....home (table page).....create.....read (user profile - form.....update....adapter curl -s https://api.github.com/markdown/raw -X "POST" -H "Content-Type: text/plain" --data-binary "@J:/awww/www/readme.md" >> "C:\Users\ss\AppData\Local\Temp\readme.htm" See J:\\awww\\www\\vendor\\erusev\\parsedown\\styles>md2h.bat
<a name="scrudU"></a> 1\.5\.6 update.phpindex.php.....index.php.....Home_ctr.....home (table page).....create.....read (user profile - form).....update....adapter
<a name="scrudadapter"></a> 1\.5\.7 Tbl_crud.php - ORM, DM (Domain Model) adapter cls - pre CRUD classSimplestCRUD index.php.....index.php.....Home_ctr.....home (table page).....create.....read (user profile - form).....update....[adapter]
<br /><br /><a name="ide"></a> 2\. My developing environment (IDE)Top......Dirs.....UML.....DM.....IDE.....CRUD.....SW fw <br /><br /><br /><a name="crud"></a> 3\. PHP 7, Bootstrap 4 : DB tbls rows PDO CRUDTop......Dirs.....UML.....DM.....IDE.....CRUD.....SW fw May be jQuery, PHP, Bootstrap AJAX DB table rows CRUD is simplest, fastest best CRUD but I prefer no jQuery AJAX . Only Javascript I need is dialog yes or no. CRUD db tables rows modules like my msg (blog) should be based on code skeleton shown in UML diagram. Non CRUD modules like my mnu and mkd : without such code skeleton may be code is simpler ? If mnu module (which is links to pages / modules) needs CRUD functionality (I think never needs), we should base it on code skeleton shown in UML diagram. Both global db classes are ~400 lines, global config class is ~400 lines - they are so small that may be included in any module. Interesting detail (solved): Msg (blog) module has no problem, but in Mnu module global ftr.php displays: Fatal error: Uncaught Error: Using $this when not in object context in J:\awww\www\zinc\ftr.php <br /><br /> $do\_pgntion attribute in class Dbconn\_allsites is used in module msg ee blog fwphp\glomodul\blog, in home.php, home_side_area.php and dashboard.php eg so :
There are not many important PHP statements in classes above, but we must understand them !! Understand means learn all conventions (which are more important then configurations). Eg : ../../../ is path to www dir ee to web server or to ISP (inet hosting) folder. $pp1 is properties global container array like Oracle forms property palette. In msg (blog) module are two masters (usr, category) 1:M posts rows, and two level of details posts 1:M comments. R O U T I N G T A B L E is in Property Palette array $this->pp1 assigned in class Home_ctr which extends Config_allsites After i/ is method in this->Home_ctr which includes/calls same named (or not) script/method or calls some (global method) or... QS=?=url adress Query separator (url query is key-value pairs). Without QS we must use Apache mod-rewrite and Composer auto loading classes instead own simple-fast auto loading. DISPATCHER includes, calls or http jumps only to other module. So we may not use constants but module property palette $pp1 which contains globals ! to be able to change $pp1 elements. cc, rr, uu, dd rows CRUD methods are used for all tables on level "all sites" !! 3\.1 B12phpfw core (CRUD) codeCore framework code we change only for new functionality and testing. Core framework code is module bootstrap, configuration, router, dispatcher - see Domain model DM for 7 module scripts which use it. Three module scripts (index.php, two classes Home_ctr.php extends Config_allsites, Tbl_crud.php) and four classes scripts global for all sites (autoload, 2xDB, conf) are B12phpfw core (programs skeleton for links = menus and for CRUD). Like any good programing templates (framework), it is not easy to understand them but is very useful !!
<br /><br /><br /> WHYNobody made OOP MVC menu and CRUD PHP code skeleton (especially for each module in own folder) clear and readable, instantly visible that it is best way of coding - hence so much blah-blah. Modules for master-detail and link tables are even more rare. Strong-talk-weak-work people pollute info space wit hypes, vapor wares... because of ignorance or to promote himself, to earn money. To simple examples plague (in 99% learning materials)Other reason : I tested ideas which seemed good, but after I added functionality (huge work !!), code was to complicated. This is why to simple examples (in 99% learning materials) are bad idea !!. We see if code (skeleton) is ok ONLY on not to simple code examples (and on more of them). Code elements (snippets, mosaic pieces) must be as simple as possible but referencing - looking at not to simple example ! I think main reason for pretty URL-s is much simpler routing. Using $\_GET variables for routing is in my experience. ok only for simple modules like my mnu, mkd, lsweb, but not for msg or oraedoop modules. > Routing - finding in URL what code call or include (calls/links constructing) > and dispatching - call or include code > was nightmare in all B12phpfw versions before 6.0 !! - main reason for so many versions. My pretty URL-s are key-value pairs, so no need for "controller/action/param1/param2..." url style ee order of url pairs is as we wish. Next Notepad++ display shows how routing is in 3 simple steps, all routings are so simple. I do not like routing-dispatching I found during learning, next is what I think best dispatching. DISPATCHING HTML DISPLAY OF MARKDOWN FILE IN MSG (BLOG) MODULE ( Routing is in Config\_allsites.php ~30 lines code) :
Explanation of code above :
WHAT
Most important modules are :
HOWImportant is to learn :
Home controller's methods include scripts or call methods according URL query parameters (uriq object). Important is that home controller's methods enable us to put some parameters in home controller's methods instead in URL - simple and clear coding. Routing table contains almost all module-in-own-folder\`s links. It is some more coding but code is very simple and clear. WHEREDirectories :
WHO, WHENI tested more than 6 versions of mnu, mkd and msg modules based on other people work mentioned below. Lot, lot of work wasted during dozen years (thanks parasits) because of strong-talk-weak-work people. There is lot of details to do for which I had no time but can be easily built on grounds given here. <br /><br /><br /> https://community.notepad-plus-plus.org/topic/17366/how-to-install-emmet-plugin/2 Meta Chuh 26 Mar 2019, 15:45 @Alexander?Rudenko Old notepad++ plugin manager is not compatible with notepad++ 7.6 and above.-it will write files to wrong locations. first revert all changes you made to your notepad++ installation, by uninstalling plugin manager and removing everything you might have installed with plugin manager. make sure you do not see any error messages at notepad++ startup, and make sure you do not see plugin manager at your plugins menu anymore. next, follow the >>> Guide: I do not use this: How to install the PythonScript plugin and emmet plugin on Notepad++ 7.6.3, 7.6.4 and above<<<, to install pythonscript manually : https://community.notepad-plus-plus.org/topic/17256/guide-how-to-install-the-pythonscript-plugin-on-notepad-7-6-3-7-6-4-and-above for notepad++ 7.6.4, 64 bit (installed version): download and extract PythonScript_Full_1.3.0.0_x64.zip from >>> here <<< to your desktop. note: do not use any other available release type, except this zip. 1. https://github.com/bruderstein/PythonScript/releases/download/v1.3.0/PythonScript_Full_1.3.0.0_x64.zip
for notepad++ 7.6.4, 32 bit (installed version): ...
now restart notepad++ and you will see both at your plugins menu :
<br /><br /><br /><br /><a name="swfw"></a> What is SW fw (Software framework)Top......Dirs.....UML.....DM.....IDE.....CRUD.....SW fw
* Linkshttp://dev1:8083/fwphp/glomodul/mkd/?edit=001_MDcheatsheet.txt http://dev1:8083/fwphp/www/ http://dev1:8083/fwphp/glomodul/mkd/?edit=01/001_db/01_oracle_DB_18c_instalac.txt http://dev1:8083/fwphp/glomodul/mkd/?edit=01/001_db/02_oracle_APEX_20_1_instalac.txt http://dev1:8083/fwphp/glomodul/mkd/?edit=01/001_db/03_1oracle_apex_sales_module.txt http://dev1:8083/fwphp/glomodul/mkd/?edit=01/001_db/03_2oracle_apex_sales_apl_cloud.txt http://dev1:8083/fwphp/glomodul/mkd/?edit=01/001_db/devsuite10g_instalac.txt http://dev1:8083/fwphp/glomodul/mkd/?edit=01/001_db/devsuite10g_F6i_to_apex.txt http://dev1:8083/fwphp/glomodul/mkd/?edit=01/001_vbox/001_instalac_moj_vbox_oralin76.mkd http://dev1:8083/fwphp/glomodul/mkd/?showhtml=J:/awww/www/readme.md (font Century Gothic 16) Top.....<a href="#directories" id="lnkdirectories">Dirs</a>.....UML.....DM.....IDE.....CRUD.....SW fw SimplestCRUD index.php.....index.php.....Home_ctr.....home (table page).....create.....read (user profile - form).....update....adapter |