PHP Class Name Resolution using ::class

With PHP 7+ being rolled out on many web hosting servers these days, there is an increased push to using Namespacing in PHP coding. This is also very evident in the PHP Standard Recommendations (PSR-0 [deprecated] and PSR-4 [active]) for Auto-loading defined by the PHP Framework Interop Group (PHP-FIG) that everyone seems to be following these days. One of the things that can be observed with the increase in Namespace using is the need to remember or query the fully qualified name of a class or object. This can be tricky at first glance, but evidently, since PHP 5.5, a very useful feature was added to easily get the fully qualified name of a class. This can come in very handy especially if you are creating your own PHP library or implementing a design pattern like a Factory pattern. This feature is called “Class Name Resolution” and it can be achieved by suffixing “::class” at the end of a class name, like this: ClassName::class. To demonstrate the value of this feature, I will show some example code, and also mention some useful functions that do the similar function for objects. Continue reading “PHP Class Name Resolution using ::class”

Using Javascript to get an element’s style

There are different ways to get the style of an HTML element using Javascript. The typical way that developers use to access styles of an element is the property. It is the simplest way to access style properties. However, the property has a limitation that can affect your code if you do no account for it. The property only accesses inline styles of an element, that is, styles that are specified in the style attribute of the element’s tag on the webpage. This creates a problem for most situations where the style is specified in a separate stylesheet CSS file or in a CSS style declaration in the head of the webpage. Fortunately, there is a simple way to deal with this in Javascript. Continue reading “Using Javascript to get an element’s style”

How to install Phing on WAMP Server 64 bit

I have been doing my Joomla extension development on my Macbook Pro for the last 8 years, and my setup involves some very simple tools. On my Mac, I used MAMP and BBEdit. My workflow involves using Git for version control, MAMP for testing my extension on Joomla, and Phing for building the extension. Recently, I have decided to migrate some of the work to a Windows 10 laptop, and I decided to go with WAMP Server 3.1.6 64 bit as my server testing environment.

So after installing WAMP Server on my Windows machine, I needed to setup Phing. I wanted to share my process of setting it up because I encountered some problems along the way that took quite a bit of searching to figure out. So, I hope that my steps below will help someone to have a smooth installation of Phing on their Windows machine. Continue reading “How to install Phing on WAMP Server 64 bit”