Setting up your local development environment with MessageBird

⏱ 10 min read

In this MessageBird Developer Tutorial you’ll first learn how to get started with MessageBird by setting up first your local development environment.

MessageBird provides an SDK (Software Development Kit) for PHP. This helper library facilitates interactions between your PHP application's code and the MessageBird APIs, so you do not have to craft raw REST API requests.

Install PHP

Make sure that you have at least PHP version 5.3 installed on your computer, as this is the minimum version of PHP that the SDK requires; we recommended you to always use the latest version of PHP.

Open a terminal and run the following command:

php -v

Your terminal should reply with something like this:

PHP 7.1.16 (cli) (built: Mar 31 2018 02:59:59) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

If this message indicates an older version or you do not get any PHP version at all and something like php: command not found instead you need to install or upgrade PHP. We’ll explain you how.

Mac

PHP is available on every Mac by default. If you are not happy with the version of PHP that comes with your Mac you can install PHP through Homebrew:

  1. If you have not used Homebrew before, download it following the instructions on its homepage.
  2. Type brew install php in your terminal.

Linux

PHP is typically available through your distribution's package manager, such as yum for RedHat/CentOS based Linux distributions or apt-get for Debian/Ubuntu. Alternatively, you can compile PHP from source following the instructions on php.net.

Windows

Windows users have a several of options for installing PHP:

Install Composer

Composer is PHP's package manager. While it's not a part of the PHP installation itself, it’s a de-facto standard that virtually every modern PHP library uses. You may be able to get the MessageBird SDK running without Composer, but we won't support it. Composer can be installed globally or locally for a single project. We recommend global installation so you can use it in multiple projects.

To confirm Composer is installed, open a terminal and run the following command:

composer -V

Your terminal should reply with something like this:

Composer version 1.7.1 2018-08-07 09:39:23

If this message indicates an ancient version or you do not get any Composer version at all and something like composer: command not found instead, you need to install or upgrade Composer.

Don’t worry! Upgrading is easy, just type composer self-update.

For a new installation simply follow the instructions on getcomposer.org for Mac/Linux or Windows.

Install the MessageBird SDK

As we mentioned, you should use Composer to install the MessageBird SDK for PHP. The SDK is open source and you can browse the code in this GitHub repository; it’s also listed on Packagist so that Composer knows where to find it. SDKs and other libraries are always installed for each project as a dependency and stored in a project-specific directory called vendor that Composer manages.

There are two ways to add a package with Composer:

Using the Require Command

Create a new project directory or open an existing project directory in your terminal. Then, type the following command:

composer require messagebird/php-rest-api

This command installs the latest version of the SDK and automatically creates or updates the files composer.json and composer.lock. 😎

Using composer.json

Create a new project directory or open an existing project directory. In this directory, create a file called composer.json; if you already have this file, you can add the SDK to it; if you only have the SDK in it, the file should look like this:

{
"require": {
"messagebird/php-rest-api": "^1.10"
}
}

Keep in mind that you have to specify the version of the SDK in the file. You can see the available SDK versions on Packagist and learn more about different ways to specify versions, for example with ranges, in the Composer documentation.

After saving the file, open a terminal in the directory into which you've stored it and type this command:

composer install

Nice work! 🎉

Your PHP development environment and project directory are ready now!

Start building!

Your PHP development environment and project directory are ready now. Let's head over to the next MessageBird Developer Tutorial and learn how to send your first SMS using PHP.

Want to start building your solution but not quite sure how to get started? Feel free to let us know at support@messagebird.com; we'd love to help!

Questions?

We’re always happy to help with code or other doubts you might have! Check out our Quickstarts, API Reference, Tutorials, SDKs, or contact our Support team.

Cookie Settings