WordPress staging site with GIT

WordPress staging site with GIT

If your WordPress website is more than just a “static” site with a blog, ie, you are running an actual application with custom developed code then you probably want to set up a staging environment to manage your updates. In this example we’ll take a look at managing our workflow using Bit Bucket as our GIT repo and using the excellent Github updater plugin (which inspite of its name does work with Bit Bucket).   Setting it up Your first…

Read More Read More

WordPress Object Cache with Redis

WordPress Object Cache with Redis

WordPress has a built in Object Cache, as described here: WP_Object_Cache. Essentially this is a key / value store so that you can cache “objects” such as database query results to avoid the computationally expensive tasks on each page load. Redis is an in memory cache. Being in memory its super fast. In a previous post we showed installation instructions for redis, so won’t repeat those again. W3 Total Cache is my WordPress Caching Plugin of choice. What I love about…

Read More Read More

Auto Loading in PHP

Auto Loading in PHP

Auto loading in PHP is the means by which to load classes (and traits and things!) without needing to specifically require the class file. On smaller projects with one or two classes and a handful of files this might not seem like a big deal, but on larger project, particularly with classes from different vendors, and in frameworks like Laravel, auto loading becomes particularly important. Our file structure To follow this PHP autoloading tutorial you should be aware of our…

Read More Read More

Using Composer Dependency Manager

Using Composer Dependency Manager

In days gone by when you wrote a project in PHP you would often write all parts of the project yourself, or you probably had code components from previous projects that you copy and pasted into your new project. You may even have gotten a third party library from the web. Of course in these days gone by you also had to figure out how to load the code into your new project. Composer Dependency Manager came along and changed…

Read More Read More

Facebook Share Button Missing Image

Facebook Share Button Missing Image

  On one of my client’s sites they have the regular social sharing icons. When a visitor clicks on the share to facebook link it populates that share with some default info, and very importantly the image. This is important to them because they run image voting sites. I was asked to see if I could fathom why the image was missing on facebook sharing. The first thing I checked was the open graph (OG) tags on the site. The…

Read More Read More

PHP Traits

PHP Traits

What are PHP traits? In genetics, traits refer to a characteristic or an attribute in your DNA. For instance, you have a trait for eye colour, or hair type. In PHP traits refer to a set of common functions which can be used by multiple classes. I think of it almost as “includes for classes” (don’t quote me on that, its just a conceptual way of looking at it). As with most programming languages, PHP is easiest learned by example,…

Read More Read More

Dependency Injection

Dependency Injection

Dependency injection is a design pattern which allows you to inject your dependencies into a class, rather than have them loaded from within that class. This blog post on PHP dependency injection will be an example based post without too much commentary from me.   Typically when we write our classes they require functionality from other classes. One way of achieving this is to include and load a new instance of the dependency within our class. Another possibility is that…

Read More Read More

Zend Opcache improves page load speed

Zend Opcache improves page load speed

Zend Opcache in PHP improves your page speed by compiling code into machine code and storing the byte code in RAM. With each subsequent hit to a resource code is served from memory rather than being compiled again. PHP is an interpreted language. What this means is that unlike languages like C / C++, PHP is not compiled once to machine code and then executed from the binary each time. With PHP, each time a page is viewed on your…

Read More Read More

PHP Queues with php-resque

PHP Queues with php-resque

If you’ve been doing PHP development for more than a week you’ll have heard about the benefits of message queues. If you’re totally new to this world and have not heard of queues you should google for more info. At its most basic though a message queue allows your application to offload long running tasks to be completed as background tasks, thus speeding up the front end for your visitors. For instance, on CuteBaby.co.za when a user registers their little…

Read More Read More

WordPress errors uploading images

WordPress errors uploading images

During work on Cutify Media Marketing’s new WordPress competition sites I encountered a problem with WordPress image uploads. The following code was called to attach an uploaded image to a WordPress post and set it as the WordPress featured image, or post thumbnail as its called in the code.. The problem is that the code kept failing. We checked the logging of is_wp_error and found the following error: Our site uses SSL (https://), however on the server itself we use a…

Read More Read More