We all know that the environment around us has a major effect on how we live and work. To get a better insight we decided to look what was currently available on the market that we could use to gain these insights. a device that would take a range of readings such as temperature, light levels and air quality. As well as this we wanted a device that had an API that would allow us to use the data is was producing in a way that we wanted to.

After spending some time we decided to go with Cubesensors, these amazing devices are not only great value for money they also ticked all the boxes for what we were looking for they read the various markers we were looking for and had a open API we could use, and to top it all off they are beautifully designed and don’t look out of place in the office.

After receiving the device and base station we looked into the API and what PHP packages if any were available to help with consuming the API and pulling data out. After some research we decided to go ahead and write our own package that we would open source and allow other people to contribute to and use.

Our Approach

Creating a Open Source PHP Package

The initial idea behind building a new package was to help make it easy for other developers to pull data out of the Cubesensors API. To do this we decided to leverage a number of other popular PHP Packages to handle things like OAuth authentication to connect to the API and retrieve the access credentials that a user would need to use any of the other endpoints on the API.

For making the requests to the API we used the popular Guzzle package, we also used the ohmy-auth package to handle the OAuth side of the API, using both of these well used and well tested packages helped speed up development of ours.

On top of these two packages we built a wrapper that would automatically attach the required tokens for the authenticated end points and return a formatted response for the user to use as they need.

Package Used

As previously mentioned we used other PHP packages to help write the Cubesensors PHP Package, these can be found in the composer.json for the package, we have also listed them below.

Platforms we develop for

  • php-logo
  • laravel-i-slant
  • WordPress
  • vue-logo