How to write Cloud Functions and libraries

cloud functions documentation and libraries

In our last blog post, we told you about the late nights spent developing our Cloud Functions.

Today, we are proud (albeit sleep-deprived) to announce another significant update.

The revised documentation section covering everything Cloud Function now includes the basics of writing Cloud Functions, predefined methods to make tasks easier and partners integration.

While reading the documentation you will discover a few new things about Cloud Functions. For example, as part of the standard library of methods, you will now have the ability to “include” Cloud Functions from each other. Why does this matter? It means you can move all common business logic (used throughout your Cloud Functions) into a separate Cloud Function in the form of PHP function declarations.

Boom! You’ve effectively created a Library Cloud Function. Once your library is ready you can include it from other functions using our include_cloudfunction() method.

For example imagine declaring a Cloud Function called “my-app-library”

A second Cloud Function, called directly by the app, can gain access to the methods declared in our first library simply by including it.

We have created a few more standard methods to give you access to the user and device information for example. With your feedback and ideas we hope to keep building this library of standard methods available to Cloud Functions.