Bruno is a professional web developer from Croatia with Master's degrees in Computer Science and English Language and Literature. After having left his position as lead developer for a large online open access publisher, he now works as the PHP editor for SitePoint and on various freelance projects. When picking them, he makes sure they all involve new and exciting web technologies. In his free time, he writes tutorials on his blog and stalks Google's job vacancy boards.

Bruno's articles

  1. Quick Tip: Get a Homestead Vagrant VM Up and Running

    This quick tip will show you how to get a working Homestead Vagrant Box up and running in no time. Note, this quick tip is based on homestead_improved, my own version of Homestead which doesn’t ask you to deal with SSH keys and automatically forwards port 5000 in order to accommodate Heroku’s Foreman tool. Relevant […]

  2. How to Install PHP Extensions from Source

    Sometimes it’s hard to know which PHP extensions you’ll need before you install PHP. In cases where you need to add extensions later on, you might get lucky and the extension could be in the repository of the OS you’re using. It might just be a simple sudo apt-get install php5-intl away. In other cases, however, you might need to install it from source – Phalcon is one such case, but it makes the procedure extremely simple by introducing vendor support, shortcuts and pre-written instructions for your OS to carry out. What if there’s no such thing for other extensions, though?

    In this tutorial, we’ll go through installing some custom extensions on Linux systems (and OS X – the process is nearly identical). The procedure is very similar to what we already did on Nitrous.io, but adapted for local environments – more specifically, Laravel Homestead. You can easily derive installation instructions from this tutorial and apply them to other distros.

    Booting the VM

    If you haven’t already, read the Homestead post linked above and get it up and running. Immediately after running a new Homestead box, you should be able to do this:

    That’s perfectly fine, this happens because the folder that’s mounted by default actually doesn’t contain any files yet. Now vagrant ssh into the VM, and execute the following commands:

    cd Code
    git clone https://github.com/Swader/publicinfo

    This creates a valid PHP Info file in the path that Homestead is set to by default. Refreshing the URL will now produce a PHPInfo screen:

    Prepping the Environment

    To build extensions from source, we need the PHP dev tools installed on our machine, as well as a compiler that can produce the extension file. Here’s how you install these prerequisites on various operating systems:

  3. Stress-test your PHP App with ApacheBench

    This article was sponsored by New Relic. Thank you for supporting the sponsors that make SitePoint possible!

    There’s no telling when your app might attract a throng of visitors at once – maybe it’s a Hacker News post that’s submitted at a specific second on a specific time of day (as posts there tend to work), maybe it was a particularly well placed Reddit post, and maybe it’s actually good and people noticed it, spreading it virally. Regardless of the reason, massive influxes of visitors are a double-edged sword: they get you what you always wanted – a chance to prove your worth to a large chunk of the internet’s population – but also often bring with them what you always feared: absolute downtime.

    There are several ways to try and prevent this – among the most prevalent is deploying your application on a service like Amazon, Google App Engine or Heroku which have the ability to not only scale out and in rapidly at your command, but also support automatic scaling, if you’re not afraid of DDoS attacks also scaling your bills while you’re asleep. These platforms usually offer plugins that can optimize your application while it’s up, so you can fine tune it as you go along, but why not try and predict issues while still developing locally and save yourself time, money and effort in the long run?

    Apache Benchmark

    ApacheBench (also known as “ab”, the command you run it with) is a tool designed to nuke an endpoint with requests and load-test web servers. It supports a wide array of parameters and options you can tweak to simulate different loads, like number of requests, number of concurrent requests, extra headers, falsified cookies, and more.

    ab is often included with every Apache installation, but if not, you can easily install it by running sudo apt-get install apache2-utils. The current version of Laravel Homestead doesn’t have it, so if you’re following along please install it into that VM when you vagrant up and connect through SSH.

  4. 8 Must Have PHP Quality Assurance Tools

    Quality Assurance in PHP is a valuable but very rarely seen aspect. In a world focused on rapid deployment and a “ship now, worry later” mentality, a focus on quality is a rare sight, especially when dealing with the web. One of our authors recently directed my attention to Sebastian Bergmann’s site, PHP QA Tools.

    The site is a simple list of interesting tools that can help you properly test your application, while also analyzing it and producing interesting data for you to look at. This post will be little more than a re-iteration of some of those tools with added information, use cases and advice about them – however, we’re open to expanding this list with other QA tools you throw our way that get plenty of votes in the comments below or seem interesting and/or useful enough.

    1. PHPUnit

    Mr. Bergmann’s own PHPUnit is, unsurprisingly, present on the list. PHPUnit is the most widely used and fully featured unit testing tool which we’ve covered extensively before – I believe it needs no further introduction.

    PHPUnit can be installed globally, by running composer global require "phpunit/phpunit=4.1.*".

    2. Behat

    Behat, a BDD framework, is a framework which will be covered in great detail on our channel soon, but in a nutshell, it allows you to write highly readable feature tests – tests that can be easily understood by even non-technical people. They’re actual stories you write, in this form, as per their site:

    Scenario: List 2 files in a directory
      Given I am in a directory "test"
      And I have a file named "foo"
      And I have a file named "bar"
      When I run "ls"
      Then I should get:
        """
        bar
        foo
        """

    You then write classes with methods which define the specific sentences, such as:

    /** @Given /^I have a file named "([^"]*)"$/ */
        public function iHaveAFileNamed($file)
        {
            touch($file);
        }

    in which Behat automatically passes the argument into the function based on what you placed between the quotes.

  5. Help Develop PHP: 5.6 RC1 on Homestead

    Last week we talked about Laravel Homestead, a prepared local development environment for PHP built on Vagrant by Taylor Otwell, meant to serve as a common starting point for all Laravel (and possibly other PHP) projects. If you’ve missed that post, I encourage you to give it a read and get familiar with Homestead as your next starting environment.

    A week before that, we talked about the end of beta for 5.6, and the beginning of the RC program. The PHP core development team encourages people to play around and test with RC editions, and to submit build feedback back to them, so that they may gather some usage statistics and possible build errors to address in the next release. PHP 5.6 RC1 has been released some days ago, and can be downloaded.

    In this post, we’ll have a quick look at how we can install it over the regular PHP in Laravel Homestead and report the build feedback back to the QA site.

    Set up

    To prepare, please read the original Homestead article and follow it to the letter until you have a working VM up and running.

    Then, SSH into your VM by running vagrant ssh. Once inside, download the latest source via wget, like so:

    wget http://downloads.php.net/tyrael/php-5.6.0RC1.tar.bz2

    Depending on when you read this, the link may be different due to other RCs already being out. Next, unpack the downloaded archive and change the directory to the newly created one.

    tar xvfj php-5.6.0RC1.tar.bz2
    cd php-5.6.0RC1

    Prerequisites

    To build PHP from source in its most basic form, there’s one dependency we absolutely need. Run the following command:

    sudo apt-get install libxml2 libxml2-dev

    You might have to run sudo apt-get update if you get an error regarding the IP address from which Aptitude attempts to fetch libxml2-dev. Then, re-run the above command (see gif below). Next, run:

    ./configure --enable-fpm

    We need to enable FPM because the Homestead PHP is built as FPM and Nginx consumes it as such. If we want to replace the Homestead-installed PHP with our own, we need to enable-fpm before compiling.

  6. 6 Reasons to Move to Laravel Homestead

    Laravel Homestead is, in a nutshell:

    an official, pre-packaged Vagrant “box” that provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine.

    In other words, it automatically does what we’ve done before manually through Vagrant and PuPHPet in articles like these.

    So what makes it different from your run-of-the-mill Vaprobash/Vagrant/PuPHPet setup? Let’s see.

    1. It Works

    Unlike the other popular solutions out there for simplifying Vagrantfile setups, Homestead seldom fails to boot, and if it does, it’s fixed within minutes. If you’ve dealt with GUI Vagrant solutions, you’ve likely noticed how rare it is to get it all up and running after the very first vagrant up. It’s always something like an outdated or over-updated Puppet, out of date Ubuntu repos, or some other cryptic error that requires vigorous “foruming” to deconstruct. Homestead simply… works.

    Homestead installs on Ubuntu 14.04. with PHP 5.5, so as new as it gets without diving into beta/RC territory, Nginx (because we’ve all given up on Apache by now, right?), MySQL and Postgres so you’re instantly ready for Heroku as well (their default is Heroku Postgres), Node (for all your static resource compilation needs, background tasks, and other less business critical things, Redis, Memcached and Beanstalkd for all your caching and queueing needs, Laravel Envoy for all your remote server task needs and Fabric + Hipchat Extension so you can do application deployment through Hipchat (also known as chatops).

    2. It’s Otwell Approved

    Homestead being official, as in, made by Taylor Otwell, the father of Laravel, means it’s automatically assumed to hold to certain standards. While the Laravel community isn’t without its drama (who cares what a class is called? If a revolutionary new framework calls a model a potato, a facade, or a rocketship, it’s perfectly fine as long as the potato/facade/rocketship works), it’s the exclusivity of Taylor’s involvement with it that gives it a note of simplicity and quality that’s much needed in today’s PHP world. We’ve seen far too many open source projects ruined by team egos, zealous contributors, or incompetent jacks-of-all-trades and it’s my personal opinion that Taylor’s almost exclusive involvement in Laravel’s betterment is what makes it shine above the rest and truly allows it to compete with Phalcon in quality.

    Homestead is his own project, termed the “official local development environment”, and he’ll do everything he can to keep it high quality and make sure it always works. Anything less, and it’s a smudge on his reputation. In PHP these days, there’s no better guarantee of a project’s long term reliability, than it being (mostly) owned by a person who cares that much about quality.

    3. It’s Fast to Set Up

    Setting Homestead up is a piece of cake. Following the instructions on the documentation page, all you need to do is add the homestead box to your Vagrant (if you don’t have it yet) and clone the repo.

  7. What You May Have Missed in PHP, June 2014

    Continuing the News You May Have Missed tradition, we’re once again aggregating the latest web development related news that may have flown under your radar. We’ll be changing the title format slightly, though, to accommodate information that isn’t strictly news, but very few people know about nonetheless. We’ll also be publishing these types of posts exclusively on Sundays, as light reading that contains at least a bit of information for everyone.

    Drupalfund

    Drupalfund.us is a Drupal development crowdfunding website that has, apparently, existed for over six months. While the exposure may not be great for now, it might explode with the release of Drupal 8, which we’ve covered to some degree already. To be honest, looking at the number and funding level of various projects so far, I believe the site would have fared better without restricting itself to Drupal specifically and instead opting to go for PHP in general, but maybe specificity is exactly what will, in due time, make it outshine others.

    Currently, only two projects are looking for funding and both seem DOA, but rather recently a well known module called d8rules was funded with $16,000. Yes, that’s sixteen thousand dollars, not a typo.

  8. Announcing PHP Summer Camp

    The image above is Rovinj, Croatia – a little piece of heaven on the west coast of the Istrian Peninsula. For the third time in a row, and in a slightly different format, the PHP Summer Camp will this time be hosted in Rovinj from September 3rd to September 6th, with an optional extra leisure […]

  9. PHP 5.6 End of Beta

    On June 5th 2014, the PHP group announced the fourth and final beta of the 5.6 version. This milestone ends the beta program and begins the RC program ( currently planned for June 19th), which will from now on focus exclusively on making sure the version is stable enough for release. As is customary with a beta program, no new features were added since beta 1 – all the releases were bugfix and improvement patches only.

    Changes

    Some five months ago we published a list of upcoming new 5.6 features, and since then the PHP group has created a more approachable summary of the changes than one that can be seen in the cryptic changelogs. The list, also called the 5.6 migration guide, is an already very useful work in progress and contains a simple demo of every new feature that matters – you can check it out here.

    If you’re interested in seeing all the bugfixes through the betas, you can read the changelog on Github.

    Things we haven’t covered in our original post but which have been added in the meanwhile are:

    Exponentiation

    In a nutshell, “exponentiation via **” it’s an operator which lets you easily calculate a number to the power of another number. However, the order of execution might be counter-intuitive to some. The example states:

    $a = 2**3; // $a = 8, i.e. 2^3
    $b = 2**3**2; // $b is 512

    Most people new to the exponent operator will assume the second line groups operations as such:

  10. PhpStorm 8 – New Features

    Jetbrains is famous for the early access program on the IDEs they make – a pre-release version of the IDE is made publicly available months ahead of release time, so people have time to test it, report bugs and provide feedback. It’s like beta, just not the beta we’re used to today (modern “beta” is a kind of excuse for a product to suck for a long time). After the EAP is done, they move onto beta, fully test the features they’ve implemented and fix bugs, and only then release.

    PhpStorm, my personal IDE of choice, and one we’ve covered before, is now approaching version 8 and has had its EAP version available since March 6th, 2014. Let’s take a look at what’s coming through their changelogs and EAP posts and additionally explain the most important features with links and/or clarifications (we won’t be covering bug fixes, read the release logs for those).

    Drupal 8 Support and Multiple Cursor

    EAP 134.1456 introduced the EAP’s beginning and announced several highly requested features like: