Stony Creek Consulting, LLC

(414) 425 9547
joejvg@stonycreekconsulting.com

Setting Up Your Local Development Environment

September 29, 2018

Development is often done locally using an integrated development environment or IDE installed on a PC desktop or laptop. I feel it is the preferred development environment and one reason is security. Security can be obtained on a server but the effort can be kept to a minimum providing a good firewall is being used along with anti-malware software that is scanning in the background. Testing on a server is mandatory before delivering any project but developing locally with the following suggested setup greatly reduces the time required to build Joomla! and WordPress web sites. It does the same for your own development projects. I have added a component I am very excited about which also speeds up the development process greatly called Joomla! Component Builder.

Local Development Environment Essentials

  • A local development environment like WAMP with XDEBUG capabilities.
  • Joomla! Component Builder.
  • NetBeans or a similar Integrated Development Environment (IDE) with  XDEBUG capabilities and GitHub versioning.
  • Chrome plus its Developer Tools and developer extensions or, others like Firefox with similar features and add-ons.
  • Joomla! Debug, especially its Stack Trace, and XDEBUG compatibly including links to the source in each trace
  • Joomla J!Dump which works well for dumping within Joomla! components instead of using PHP echo and var_dump.
  • Developer Tools in Chrome is a very good source for debugging JavaScript in real-time with features similar to NetBeans debugger.
  • Developer Tools in Chrome has many other features to assist you with debugging and tweaking your site on-the fly.

Debugging Basics

Debugging tools are an essential part of any developer’s IDE. Spending hours trying to locate a run-time bug by reading through hundreds or perhaps thousands of lines of code to find a single misplaced character is exasperating and non-productive. Good debugging skills usually allow one to locate the offending line or lines of code in minutes. It’s usually easy to correct an issue, it’s almost always difficult to find where it occurred, especially with all the interconnections one finds in a component using the MVC paradigm, much less ones using the Joomla! API extensively such as Joomla Component Builder does.

In this blog I am focusing on Joomla! and in another blog I’ll be discussing WordPress. The MVC paradigm is another focal point in this blog but the same principles apply to any development paradigm or platform such as Microsoft .Net, Windows and Visual Studio. The tools are just different as is the platform they are being used on but all have common features and functions to reach the common goal which is getting the project  delivered on time, according to specifications and within budget. These tips should facilitate your analysis and your development efforts no matter what the environment is. Some of the functionality offered by a good IDE debugger are:

  • Single stepping through code while it executes
  • Adding breakpoints and watches to suspend execution and examine contents of variables
  • Stack traces that show the path of each script and resource used during execution
  • Watches to examine the contents of variables based on their contents
  • 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 and functionalities not mentioned here. Effective debugging is indispensable during the development cycle of a component. It allows you to quickly identify and resolve run-time errors. 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.

Getting XDEBUG to work with your browser and IDE can be a daunting task. This guide and another one have excellent tips on using XDEBUG with NetBeans and other IDE’s and include using it with a browser. They also have instructions on how to troubleshoot the default port it uses and how to differentiate if the default port (9000) used by XDEBUG is the issue such as it is blocked by your firewall and needs a rule to punch through it or the required lines in the php.ini aren’t there or are incorrect, or some other reason.

It is also recommended to use this excellent tool 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 plus excellent troubleshooting instructions. The php.ini lines both suggest are not needed usually so use the php.ini lines generated by the tool in the last link in this paragraph.

WAMP allows switching between 5.x and 7.x versions of PHP. To facilitate XDEBUG WAMP uses a different XDEBUG DLL in the 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 installed for the corresponding version of PHP that was compiled. Let WAMP do this for you. The previous link appears to be the best one to use for a comprehensive installation of WAMP that is a one-page-stop for everything you need. 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. It takes some time and you must install the 32 and 64 bit versions and I suggest doing it in date order starting with the earliest and ending with the latest. Read through the page completely so you install everything that is required. Follow all the recommendations that are also on the page.

You can install all of the Visual C++ Packages as you will have then have whatever version of the package is needed for whatever version you have of PHP. Do not worry that two are French. They work fine but you may need to be sure you click the OK button instead of Cancel as they are in French. Other than that all else on the page installs in English. The dependency the PHP version has with each Visual C++ Package version depends on the version of the Visual C++ Package that was used to compile the PHP version. Like anything worth the effort, do the work and read the information in the sites I have mentioned previously.

Often, XDEBUG will work if you just install it and let the installation took care of everything. Try doing that first and if everything works correctly you have the right Visual C++ Package installed and php.ini had the correct XDEBUG section that works with it. If you switch PHP versions and it stops working then you will need to ensure the environment is set up correctly for that version. This will not occur if you install all the Visual C++ Packages 32 and 64 bit. But it seems like many have issues with it as they depended on the install to do everything, including their environment, despite switching to another version of PHP.

XAMPP will install XDEBUG without much effort from you but WAMP is a much better environment to work in. The same applies for LAMP and MAMP. It is beyond the scope of this manual to go into Linux and Mac operating systems also but the same concepts apply and many of the links also refer to these operating systems.

The post Setting Up Your Local Development Environment appeared first on Stony Creek Consulting, LLC.

Posted in: Uncategorized

The Dreaded 404 Page

August 16, 2018

We all hear of the blue screen of death in Windows or the dreaded white page of death in Joomla. WordPress at times turns white, freezing up and fails to respond. Joomla is our focus in this post. WordPress later.

Let’s fire up a search engine. Dozens of conflicting posts later, you are dazed and confused. Granted, these issues can often lead to a support call unless you have the skills required. Let’s focus on a user staring at something similar, while fuming about why the page was not found:

404 Page Not Found displayError

Did it mysteriously disappear? Did one of those development types break it? little experience or someone like me who writes plenty of code but let’s someone else do it when I can.  This was a rather interesting hybrid resolution of a perplexing issue While these are more difficult to debug and resolve, after what I experienced recently made me think “I wonder if anyone else has run into this issue?” So, I would like to add a third to the list of errors we really do not want to deal with, depending on how many we have to deal with:

Nothing is more vexing than to see this error after you click a link and continue to see it on random links as you browse the site. I usually leave the site after about five (depends on number of articles) and someone less forgiving than I am usually leaves after one. I will admit I do also depending on how many articles are in the site.

Recently, one of my clients base who provides managed services for a large number of his clients started a chat with me using Skype. One of his clients was getting complaints from his vendors advertising on the site that they were seeing the error. The problem is, no one knew why. So, I started the usual troubleshooting and noticed the articles had a missing Itemid.

This Joomla! parameter, present in every Joomla URI, is often overlooked but its importance cannot be overestimated. It is required so the context of the menu option used to display the current page is retained as explained at https://www.itoctopus.com/what-is-itemid-in-a-joomla-url-and-why-it-is-important-to-have-it which ensure the modules on it display if they should display and https://www.joomlashack.com/blog/joomla/what-is-the-joomla-itemid/ has a good explanation of the role they play to ensure modules display and do so in the position intended when the new page is rendered.

Unusual aspects of the issue on this site were:

  • Determining the impact of the problem.
  • Deciding if the impact warranted adding the missing item id’s.
  • Determining what was missing the item id and where so it could be added.
  • A way to add the item id with a program if the maintenance effort warranted it.

As with many issues, the converse should be looked at. It wasn’t and a lot of work ensued but a component came out of it. Our first free offering is called OrphanCleaner which will list them for manual editing. Optionally, you can have the component correct these “Orphaned Item Id’s” in the professional version.

Another solution to the problem proved to be a simple one but at a bit higher cost than our component does. This solution may be something you could use but if not, please see the components we have to offer. The sh404SEF extension is an excellent one that I recommend highly. I have used it for years and my only comment that is common to a lot of high maintenance components is just that. Maintenance goes along with good SEO practices and sites having a lot of content, especially if it’s dynamic require it.

I found this solution searching for a link from keywords like “no item id” and “item id 404” and others. The link to sh404SEF came up from searches for fix missing item id or something similar if I recall and that led to more searches like it. Finally I just tried sh404SEF and the option to replace the missing item id’s worked.

Much later, I found this: https://joomla.stackexchange.com/questions/12178/how-to-remove-menu-item-id-from-k2-item-link

Here is what the link said so my SWAG was right on but in my case a 404 page was the result:

Itemid is the key part of Joomla Router to identify a target and navigate through the menu structure. Also, modules are associated with specific Itemids.

If there is no Itemid, Joomla renders a default page with modules assigned to ‘All’ pages.

If you are looking for a way to customize SEF and generate Urls with no IDs, then you can just install a SEF extension.

The two sites having the issue had an average of five links per page and each site had a large number of pages. Testing and checking with the site’s MSP later resulted in no issues being reported. The dreaded 404 page was gone and the mission was accomplished!

The post The Dreaded 404 Page appeared first on Stony Creek Consulting, LLC.

Posted in: Uncategorized

Blog

November 21, 2017

Welcome to the Stony Creek Consulting, LLC WordPress Blog

We use the best of both CMS worlds, Joomla and WordPress. Check back often as we add posts regularly that cover a wide variety of Information Technology topics.

The post Blog appeared first on Stony Creek Consulting, LLC.

Posted in: Uncategorized
 
 
Real time web analytics, Heat map tracking