Peter is a software architect from the Netherlands. He freelanced for more then 6 years as a web developer, and meanwhile, he graduated as software engineer with honors. He decided to join CMNTY Corporation which specializes in creating community software and is now responsible for the ongoing development of multiple web applications as well as mobile applications. Peter believes a real developer is able to combine multiple techniques together to make sure the user receives the ultimate experience and enjoys using the application. In his free time, he loves to play board games with anyone who is interested. He especially has a passion for cooperative board games.

Peter's articles

  1. Social Network Authentication: Twitter and Facebook

    This entry is part 4 of 4 in the series Using Social Networks as a Login System

    In the previous parts of this series, we created our initial interfaces, set up our Google+ login functionality and talked about how we can merge our accounts together. In this article, we will integrate Twitter and Facebook within our application. You will see a lot of similarities with the Google+ article, so if you could follow that one easily, you won’t have much trouble with this one. If you haven’t read that article yet, I suggest you read it first before continuing this article.

    You can view the code for all the articles on this Github page.

    Twitter login

    Once again, we start off by creating the following directory: src/SitePoint/SocialLogin/Twitter. Within this directory, we create the TwitterLogin class. This class implements the SocialLoginInterface interface which we created in the first article. Make sure a property called service is available to store our service in.

    Like Google+, Twitter has some specific needs to make sure we can log in. So make sure we have the following 3 properties present in the class:

    • Client id
    • key
    • callback URL

    Since all 3 properties are required for our application to work, our constructor will receive these 3 variables as parameters and set the properties.

    Up until now, your code should look the same as the first example in the Google+ article.

    Our next step is to create our Twitter service. We will be using the same OAuth library and will set up a connection within the init method.

    Before we can start, we have to add some use statements to the top of our class.

  2. Social Network Authentication: Merging Accounts

    This entry is part 3 of 4 in the series Using Social Networks as a Login System

    In this part, we will have a look at how we can make sure people don’t have multiple accounts after signing into our application through different means.

    Merging accounts

    If you allow users to sign up through different social networks and perhaps your own registration system, there is a good chance some users will have multiple accounts. How annoying can it be for a user who signed up through Facebook earlier, to come back later and log in through Twitter because he thought he used that one?We can prevent this by letting the user merge manually or try to use an automatic system to try and identify duplicated users.


    I suggest a setup of two database tables. The first table is the general user table, which contains all information about the user.

      `id` int(11) NOT NULL AUTO_INCREMENT,
      `username` varchar(255) NOT NULL,
      `password` varchar(255) DEFAULT NULL,
      `firstname` varchar(50) NOT NULL,
      `lastname` varchar(50) NOT NULL,
      `emailaddress` varchar(50) NOT NULL,
      `city` varchar(50) NOT NULL,
      `birtdate` date NOT NULL,
      `gender` varchar(10) NOT NULL,
      PRIMARY KEY (`id`)

    Note: As you can see, I used the fields that we also used in our SocialLoginInterface. You might need more or less fields depending on your application. You even could decide to split this table in a user and user_profile table if you wish.

    The second table contains all data regarding any third party logins the user used.

  3. Social Network Authentication: Google+

    This entry is part 2 of 4 in the series Using Social Networks as a Login System

    In the previous part of this series, we created our initial interfaces which we’ll be using for all future parts. In this article, we will integrate Google+ within our application.

    You can view the code for all the articles on this Github page.

    Google+ login

    We start off by creating the following directory: src/SitePoint/SocialLogin/Google. This will be the directory we will be working in for the rest of the article. Within this directory, we create the GoogleLogin class. This class implements the SocialLoginInterface interface which we created in the previous article. Make sure a property called service is available to store our service in (see code below).

    Google has some specific needs to make sure we can log in. So make sure we have the following 3 properties present in the class:
    - client id
    - key
    - callback URL

    Since all 3 properties are required for our application to work, our constructor will receive these 3 variables as parameters and set the properties.

    Until now, our code looks like this.

    namespace SitePoint\SocialLogin\Google;
    use SitePoint\SocialLogin\Interfaces\SocialLoginInterface;
    class GoogleLogin implements SocialLoginInterface {
         * Google service
         * @var string
        protected $service;
         * OAuth client ID
         * @var string
        protected $clientId;
         * OAuth key
         * @var string
        protected $key;
         * Callback url
         * @var string
        protected $callbackUrl;
         * Constructor
         * @param $clientId string
         * @param $key string
         * @param $callbackUrl string
        public function __construct($clientId, $key, $callbackUrl)
            $this->clientId = $clientId;
            $this->key = $key;
            $this->callbackUrl = $callbackUrl;
         * Initializes our service
        public function init()
         * Returns the login url for the social network
         * @return string
        public function getLoginUrl()
         * Handles the login callback from the social network
         * @param string $accessCode
         * @return SocialUserInterface
        public function loginCallback($accessCode)

    The next step is to create our Google+ service. As you have seen in the previous article, we are using an OAuth library to set up our connection with Google+. We will be using our init method to create the service.

  4. Social Network Authentication: Setup

    This entry is part 1 of 4 in the series Using Social Networks as a Login System

    Almost every website which contains a log in option, also contains ways to log in through different social networks. In this series of articles, we will take a look at how we can make sure that our visitor can log in through Google+ and eventually other networks like Twitter and Facebook. In the final article, we will have a close look at how we can make sure users don’t have different accounts due to the fact that they used different social networks.

    We will create a framework agnostic package which can easily handle users from different social networks. In this part, we will have a look at our basic setup.

    Creating your package

    We start by creating our package. For that, we just start a fresh project without any content. We first need to define what our vendor name is. In general, people use their (user)name or company name. I will use PeterNijssen as my vendor name.

    Next to that, we also need a package name. This name normally describes your package. Since we are using social networks to log in with, we will use SocialLogin as our package name.

    It’s time to create our directory structure. In general, it’s recommended to store your classes in the src directory. So let’s start by creating the directory src/PeterNijssen/SocialLogin.

    We are going to create a composer.json file, to easily maintain our dependencies.

        "name": "peternijssen/social-login",
        "type": "library",
        "description": "Social login functionality",
        "homepage": "",
        "license": "MIT",
        "authors": [
                "name":     "Peter Nijssen",
                "homepage": ""
        "require": {
            "php":              ">=5.3.0"
        "autoload": {
            "psr-0": { "PeterNijssen\\SocialLogin": "src" }
        "target-dir": "PeterNijssen/SocialLogin"

    To make sure we didn’t make any mistakes, run composer validate against the composer.json file.

  5. The Complete Guide to Nailing Your Next Interview

    So you applied for a job as a developer or designer, and now they’ve asked you to come in for an interview. Congratulations! But now the real work begins. How do you make sure you make the right impression – and get the job? Here are some tips to help you nail your next interview.

    Preparing for the Interview

    Getting to know the company

    You probably already took a good look at the company’s website when you wrote your application letter. Now it’s time to dive deeper into the company by checking out every page, and also looking elsewhere for more information.

    Try to see what the company does and what they value. Search for the company name to see if you can find out a bit more about the company’s history. Take notes, the information you find will form the basis of any questions you may want to ask.

    You might find some negative information about the company. If during the interview something is mentioned about this, feel free to ask more about it. Depending on what it is, it could be something sensitive which they would prefer not to talk about. So don’t push harder then necessary.

    It’s also good to research your interviewer. Maybe you have common interests which you can mention during the interview. If you’re both fans of the TV series Game of Thrones, for example, you could mention that to give you something to talk about which is not work related.

  6. Continuous Integration with PHP-CI

    Creating an application is one thing. Keeping it to a certain quality level is another thing entirely. These days, you can find many tools which can help you to keep the quality of your application in shape. Running these tools one by one can be very time consuming. For that, you can install so called continuous integration (CI) services. PHPCI is one of those and in this article, we will dive into it.

    Continuous integration service

    A continuous integration service is an application which runs certain quality check tools against your code. For example, a CI could pull in your git repository. When done, it runs unit tests, checks your code for validations and generates reports based on it. In general, a CI runs on certain time intervals or on every push. The most seen situation is right after creating a merge request. By checking the merge request, the code is checked before being merged, making sure you are not accepting code which could break functionality. So integrating CI within your development procedure can make sure bad code is kept out of your main repository and you can validate automatically if everything meets your requirements before accepting changes.


    Installation can be done in two different ways. Either you download the latest release or you follow the installation guide. I decided to go with the installation guide and install it through Composer. After running composer update you can run the install script. You will be questioned for database credentials and your email address. When done, a user is created with the given email address.

    You also need to set a cronjob so builds are run automatically.


    Depending on what you want to do, you have to install some tools. After logging in, you can go to admin manage plugins and install any necessary plugins. By installing a plugin, you are updating the composer.json file with new requirements. So right after you installed the plugins you need to run composer update to actually install these plugins.


    Add a project

    By clicking the add project button in the header, you can create a new project. You have to fill in a simple form, which indicates were the code is located. You can choose between different kinds of services like Github and Bitbucket, but also for your own remote or local URLs. If you don’t have a phpci.yml configuration file within your repository, you need to provide the build configuration. Within his configuration, you define how the project needs to be set up, which tools you want to run and how to finalize the build.

    Each build process consists of 5 phases.

    1. Setup. The phase were everything is initialized
    2. Test. The phase were all tests are executed
    3. Complete. Success or failure, this part will always run
    4. Success. Will only be run in case of success
    5. Failure. Will only be run in case of failure

    I will be using this project as our project. We want to ignore default directories like app and vendor. Installation will be done through Composer. The project should be PSR2 compliant, has unit tests and contains decent docblocks. We also want to check if the overall quality is fine by running PHPMD, PHPCPD and PHPLoc.

    PHPCI is capable of handling a test database. However, the project we are using in our example does not have any functional tests, so we will leave out the MySQL connection.

    Let’s take a look at what the configuration would look like.

  7. Mock your Test Dependencies with Mockery

    Although not everyone is doing it yet, testing your application is one of the most essential parts of being a developer. Unit tests are the most common tests to run. With unit tests, you can check if a class behaves exactly like you intended it too. Sometimes, you are using a third party service within your application and it’s hard to get everything set up to get this unit tested. That’s exactly when mocking comes into play.

    What is mocking?

    Mocking an object is nothing more than creating a stand-in object, which replaces the real object in a unit test. If your application heavily relies on dependency injection, mocking is the way to go.

    There can be several reasons to mock objects

    1. When performing unit tests, it’s best to isolate the class. You don’t want another class or service to interfere with your unit test.
    2. The object doesn’t exist yet. You can first create the tests, then build the final objects.
    3. A mock object is in generally faster than preparing a whole database for your test.

    When running unit tests, you are probably using PHPUnit. PHPUnit comes with some default mocking abilities as you can see in the documentation. You can read more about mocking in general and the mocking abilities from PHPUnit in this article written by Jeune Asuncion.

    In this article, we will dive into Mockery, a library created by Pádraic Brady. We will create a temperature class which gets a currently non existing weather service injected.


    Let’s start by setting up our project. We start off with a composer.json file which contains the following content. This will make sure we have mockery and PHPUnit available.

        "name": "sitepoint/weather",
        "license": "MIT",
        "type": "project",
        "require": {
            "php": ">=5.3.3"
        "autoload": {
            "psr-0": { "": "src/" }
        "require-dev": {
            "phpunit/phpunit": "4.1.*",
            "mockery/mockery": "0.9.*"

    We also create a PHPUnit config file named phpunit.xml

        <testsuite name="SitePoint Weather">
            <listener class="\Mockery\Adapter\Phpunit\TestListener"

    It’s important to define this listener. Without the listener, methods like once(), twice() and times() won’t thrown an error if they are not used correctly. More on that later.

  8. Enable PhpMyAdmin’s Extra Features

    PhpMyAdmin is one of the most used tools when it comes to managing you databases. By default, PhpMyAdmin does a great job. However, it comes with a lot of handy extra extensions which can be easily activated. In this article, we will activate these extensions and see what they can do for us.


    Before you can continue, please make sure PhpMyAdmin is up and running. After logging in, you will probably notice this message at the bottom of the main panel:

    The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. To find out why click here.

    Clicking on here will lead you to a page indicating that you didn’t activate all extensions yet. You can activate them, by changing the file and adding the following lines.

    $cfg['Servers'][$i]['controluser'] = 'pma';
    $cfg['Servers'][$i]['controlpass'] = 'pmapass';
    $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
    $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
    $cfg['Servers'][$i]['relation'] = 'pma__relation';
    $cfg['Servers'][$i]['table_info'] = 'pma__table_info';
    $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
    $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
    $cfg['Servers'][$i]['column_info'] = 'pma__column_info';
    $cfg['Servers'][$i]['history'] = 'pma__history';
    $cfg['Servers'][$i]['recent'] = 'pma__recent';
    $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
    $cfg['Servers'][$i]['users'] = 'pma__users';
    $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
    $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
    $cfg['Servers'][$i]['tracking'] = 'pma__tracking';
    $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
    $cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
    $cfg['Servers'][$i]['favorite'] = pma__favorite’;
    $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';

    Change the username, password and database name to your own liking. All the other config values are table names. By leaving these blank, you will deactivate these extensions. However, if you want to activate any, I would suggest to keep the same name as I provided above. Depending on your PhpMyAdmin version, not all config values will be available by default. In this case, I used the 4.2.x version of PhpMyAdmin.

  9. Codeivate – social coding RPG

    When building a web application, you are probably using more than one language to get the job done. Maybe you are wondering how much focus you are actually giving different languages? These days, you can track that through Codeivate.

    Codeivate is a tool which you can integrate with several editors like PhpStorm and Sublime Text and which will track the kind of files you are working on and award you points for that. In the end, you can see a complete profile of what you have been programming in and which languages you are using the most. See my profile on Codeivate for an example.


    Integration with several editors is easy. In this article we will have a look at the integration with PhpStorm and Sublime Text. Do note, however, that more editors are currently supported and coming soon.

  10. Optimizing MySQL Bottlenecks

    This entry is part 3 of 3 in the series Optimizing MySQL

    This entry is part 3 of 3 in the series Optimizing MySQL Introduction MySQL is one of the most used databases in conjunction with PHP. Making sure that your MySQL databases are running at their best is one of the most important aspects you have to consider whenever your web application grows. In this series […]