Pragmatism in the real world

Converting a Composer dependency to git for editing

I'm adding a new feature to ZF's Problem-Details component and it's easiest to do this within the context of the application I'm developing. The component lives in vendor/zendframework/zend-problem-details and was installed using composer require so doesn't have its own git repository as the distribution zip file was used to install it. To change it to a git repository, we can use the –prefer-source option and specify a branch like this: $ composer require –prefer-source zendframework/zend-problem-details:dev-master… continue reading.

Custom URLs for a Cloud Foundry application

Now that I have my application deployed to Cloud Foundry, I need it to work with my own domain, such as bookshelf.akrabat.com rather than slim-bookshelf.eu-gb.mybluemix.net. We can do this via the command line which is useful. To do this we need to create a domain and then we can create a route. Create a domain To create a domain, we use the command cf create-domain {organisation name} {domain name}. For me, my organisation is "19FT",… continue reading.

CORS and OpenWhisk web actions

By default, OpenWhisk will handle the relevant responses for CORS. Specifically, it will respond to an OPTIONS request with these headers: Access-Control-Allow-Origin: * Access-Control-Allow-Methods: OPTIONS, GET, DELETE, POST, PUT, HEAD, PATCH Access-Control-Allow-Headers: Authorization, Content-Type If you need to change what is sent or you don't want to send these headers at all, then you need to do set the annotation web-custom-options to true and handle the OPTIONS header yourself. Note that if you don't set… continue reading.

CLI credentials for a Cloud Foundry database

If you need access to your Cloud Foundry database from the command line the easiest way to get a set of credentials is to create a service key. This is done using the command cf create-service-key {service-name} {key-name}. You can call the key anything, so to connect to my database that I created previously: $ cf create-service-key slim-bookshelf-db ROB_CLI Creating service key ROB_CLI for service instance slim-bookshelf-db as rob@19ft.com… OK Now that we've set up… continue reading.

Using PostgreSQL with PHP in Cloud Foundry

Having successfully deployed a PHP application to Cloud Foundry, I needed a PostgreSQL database for persistent storage. I found Lorna Mitchell's Connecting PHP to MySQL on Bluemix helpful and this article expands on that information. I want to create a cloud-based PostgreSQL database and connect it to Laravel's Eloquent in a Cloud Foundry application. This is how to do it. Create the database instance As I'm using Bluemix for my Cloud Foundry hosting, I'm using… continue reading.

Deploying a PHP application to Cloud Foundry

I recently had a requirement to deploy a Slim application somewhere. As I already have a Bluemix account, it seemed sensible to deploy it to their Application Runtimes service which is an installation of the Open Source Cloud Foundry project. This turned out to be quite easy, but there are a number of steps involved, so I'm documenting it here. Setup the CLI tools I'm a command line person, so did it all via the… continue reading.

Adding a user to your Bluemix space

I'm at the stage where I need to give another developer access to my IBM Cloud Functions actions. I'm not really an infrastructure person and I found the user management pages on the Bluemix console incomprehensible, so used the command line. This is how I did it so that I don't have to work it all out again. Add the user to your organisation These are the steps to add the user to your organisation:… continue reading.

Getting started with Serverless PHP

I've been interested in Apache OpenWhisk for a little while now and recently submitted a new feature to add PHP support to the project. As OpenWhisk is a serverless environment, most users do not run their own copy and instead use a commercial provider with IBMs Bluemix available now along with Adobes I/O Runtime and RedHat coming soon. As a result, my contribution, isn't practically useful until it's in production with a provider. Fortunately, and… continue reading.

Logging in to Bluemix via wsk

To set up the authentication for the OpenWhisk cli tool wsk you do this: $ wsk property set –apihost {host} –auth {key} > /dev/null $ wsk property unset –namespace > /dev/null The host and key are provided to from your OpenWhisk supplier. For Bluemix OpenWhisk, you can find it by logging in and then going to the Download OpenWhisk CLI page. To make my life easier, I use a bash function to swap OpenWhisk environments… continue reading.

Creating an OpenWhisk Alexa skill

In a previous post, I looked at the mechanics of how to create an Alexa skill to tell me which colour bin I needed to put out next. I'll now look at how I chose to implement it in OpenWhisk, using Swift. An Alexa skill consists of a number of intents and you register a single end point to handle them all. As I'm using OpenWhisk, I have direct web access to my actions without… continue reading.