Updated 4a. JCB Demo Component Directory, Folders and Files (markdown)

Joseph Geller
2018-09-19 13:00:46 -05:00
parent 786650a9df
commit f996f08308

@@ -13,7 +13,7 @@ The JCB Demo component analysis presented in this chapter will introduce you to
* A local development environment like [WAMP](http://wampserver.aviatechno.net/?lang=en&prerequis=afficher) with native [XDEBUG](https://xdebug.org/) capabilities
* Joomla! Component Builder
* [NetBeans](https://netbeans.org/) or a similar Integrated Development Environment (IDE) with native XDEBUG and GitHub functionality
* [Chrome](https://www.google.com/chrome/) plus its Developer tools and developer extensions or, others like [Firefox](https://www.mozilla.org/en-US/firefox/new/) with similar features and add-ons
* [Chrome](https://www.google.com/chrome/) plus its [Developer Tools](https://developers.google.com/web/tools/chrome-devtools/) and [developer extensions](https://chrome.google.com/webstore/category/ext/11-web-development) or, others like [Firefox](https://www.mozilla.org/en-US/firefox/new/) with similar features and add-ons
* Joomla! Debug, especially its Stack Trace, and XDEBUG compatibly including links to the source in each trace
There are [many other possibilities](https://docs.joomla.org/Setting_up_your_workstation_for_web_development), especially with the IDE, but this combination integrates well, and much of its features are native to the applications comprising it. This also applies to any other components used as examples in the videos and chapters accompanying them in this manual. Keep in mind as you progress through them the complexity of the components being shown as examples will increase. The directory tree will look more complex, and contain many additional files. However, they all share one thing in common which is the MVC paradigm; all follow its basic directory structure and naming conventions, including the files contained in it. This also includes the locations of the files. The code and necessary constructs specific to a Model, View or Controller for each to function and interconnect with each other and the Joomla! API at the most basic level are common to all, if developed using the MVC paradigm in its strictest sense.
@@ -37,9 +37,11 @@ Debugging tools are an essential part of any developer's IDE. Spending hours try
* A dump of all variables in play while single stepping through the code
* Easily examining classes, methods, and properties including their source on the fly during execution
There are [many other features](https://netbeans.org/kb/docs/php/debugging.html) and functionalities not mentioned here. Effective debugging is indispensable during the development cycle of a component. It enhances the JCB build process and allows you to quickly identify and resolve issues in the component after JCB has compiled it successfully, but the component has run-time errors. Also, make use of Joomla's! built in debugging enabled in its configuration settings. The stack trace it displays, including links if using XDEBUG, are also indispensable. Plus, it integrates with an IDE like NetBeans using the [Chrome NetBeans extension](https://chrome.google.com/webstore/detail/netbeans-connector/hafdlehgocfcodbgjnpecfajgkeejnaa?hl=en).
There are [many other features](https://netbeans.org/kb/docs/php/debugging.html) and functionalities not mentioned here. Effective debugging is indispensable during the development cycle of a component. It enhances the JCB build process and allows you to quickly identify and resolve issues in the component after JCB has compiled it successfully, but the component has run-time errors. Also, make use of Joomla's! built in debugging enabled in its configuration settings. The stack trace it displays, including links if using XDEBUG, are also indispensable. Plus, it integrates with an IDE like NetBeans using the [Chrome NetBeans extension](https://chrome.google.com/webstore/detail/netbeans-connector/hafdlehgocfcodbgjnpecfajgkeejnaa?hl=en). Getting XDEBUG to work with your browser and IDE can be a daunting task. [This guide](https://quantumwarp.com/kb/articles/87-netbeans/928-debugging-with-netbeans-xdebug-and-xampp-in-windows) and [another one](https://articlebin.michaelmilette.com/making-xdebug-work-with-netbeans-on-windows/) have excellent tips on using XDEBUG with NetBeans and other IDE's and include using it with a browser. It is also recommended to use [this excellent tool](https://xdebug.org/wizard.php) as it creates the necessary php.ini lines you will need to replace what NetBeans puts there which is just a stub except for the line that loads the correct DLL. The two links before that one are for understanding XDEBUG and what must be done to install it properly. The php.ini lines in them are not needed usually and the tool works just fine.
It should be mentioned for those wishing to take the quick path you can browse com_demo_v2_0_0__J3.zip directly using Windows File Explorer as one example and skim through the tree and files without extracting it. However, this is a Joomla! component install package so it will not match the directory structure. Doing this does have benefit as adn this explains hiw the package wroksFor some, this is all they require, especially if they are very experienced PHP developers, have used the Joomla! API extensively and found JCB was not very difficult to learn by just reading its code. However, if you are not at this point yet, creating the text file and performing the same analysis done here for your own component or ones freely supplied by JCB, as some are complex, is an excellent exercise. Make notes in your text file as you browse through the directories and files on your development site for later review or revisiting concepts that perhaps were not very clear at the time. Follow along as you go through the directory tree on your system. Locate and open the files in each one shown below and view its contents. Good study habits will enable you to progress quickly to become an advanced developer of components built using the MVC paradignm, JCB and the Joomla! API. Microsoft Notepad is not recommended by the way to accomplish this, despite your level of expertise. It, along with the other tools mentioned here, allows you to save a lot of time, develop more components and most importantly, adhere to the MVC paradigm which is a time-saver in itself.
Each PHP version (WAMP allows switching between 5.x and 7.x) uses a different DLL in php.ini that WAMP switches between when different PHP versions are used. WAMP current version allows switching between that last 5.x version and three 7.x versions. So, do not change what was installed by WAMP at the end of php.ini. Comment out all the lines underneath using a semicolon (;) in each php.ini used by WAMP for each PHP version it allows you to switch to which is very nice for let's say looking at latest Joomla! version, e.g Joomla! 4 alpha. Not using the correct DLL is the most common error when using XDEBUG and WAMP sets this up correctly. The other error that is very common is not having the [Visual C++ Packages](http://wampserver.aviatechno.net/?lang=en&prerequis=afficher) installed for the corresponding version of PHP that was compiled. WAMP does this for you. The previous link is the best one for a comprehensive installation of WAMP, all on one page. Since there are many versions of WAMP, although you should be using the current one, it will not hurt to install all of the Visual C++ Packages though it takes considerable time and you must install the 32 and 64 bit versions. Read through the page completely so you install everything that is required. Go to and install all of them so you will have whatever XDEBUG needs to work with whatever version of PHP was compiled. This works and has always resolved any issues I have had with XDEBUG but like anything, do the work and read the information in the sites I have linked to. It will not work if you just install it and hope the installation took car of everything.
It should be mentioned for those wishing to take the quick path you can browse com_demo_v2_0_0__J3.zip directly using Windows File Explorer as one example and skim through the tree and files without extracting it. However, this is a Joomla! component install package so it will not match the directory structure. Doing this does have benefit as and this explains how the package works. For some, this is all they require, especially if they are very experienced PHP developers, have used the Joomla! API extensively and found JCB was not very difficult to learn by just reading its code. However, if you are not at this point yet, creating the text file and performing the same analysis done here for your own component or ones freely supplied by JCB, as some are complex, is an excellent exercise. Make notes in your text file as you browse through the directories and files on your development site for later review or revisiting concepts that perhaps were not very clear at the time. Follow along as you go through the directory tree on your system. Locate and open the files in each one shown below and view its contents. Good study habits will enable you to progress quickly to become an advanced developer of components built using the MVC paradignm, JCB and the Joomla! API. It, along with the other tools mentioned here, allows you to save a lot of time, develop more components and most importantly, adhere to the [MVC paradigm](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller) which is a time-saver in itself.
Beneath the directory structure and files presented next you will find a short explanation of their relation to the component, the areas of the JCB component that builds each and JCB's interaction with the Joomla! API. You'll see how JCB reuses and extends Joomla!'s abstract base classes, including their methods and properties to implement the many features and functions built into JCB which are utilized by you while building a component. As you peruse the directory structure and files, links are available allowing you to quickly go to the explanatory text below the directory structure for that file, including a reference to where in JCB it originated from and any interaction between JCB and the Joomla! API.
***