Browsed by
Category: PHP

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

Creating a new laravel site

Creating a new laravel site

Having installed Laravel you’ll now want to create your first Laravel website. Creating the new Laravel site In the command line navigate to the parent directory which contains all your web projects. On my Ubuntu system my projects are all in /var/www/html, so on the command line: cd /var/www/html Decide on a name for your project. We’ll call ours my-cool-website. Now run the new command from the command line like this: laravel new my-cool-website            …

Read More Read More

PHP: Create an installer with composer

PHP: Create an installer with composer

Composer is the current most popular package management system for PHP. Composer is used to manage package dependencies and chances are good that you’ve used it to install software before. In this article we’ll look at creating your own installer with composer for your PHP projects. Using PHP’s dependency manager, Composer you list your project’s dependencies in a composer.json file and, with a few simple commands, Composer will automatically download your project’s dependencies and set up autoloading. You can think…

Read More Read More