Download the PHP package tkotosz/fn-fdk-php without Composer

On this page you can find all versions of the php package tkotosz/fn-fdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package fn-fdk-php

PHP Fn Development Kit (FDK)

fn-fdk-go provides convenience functions for writing php fn code

Installing fn-fdk-php

You can install it manually with composer:

Or just use the php init image to create new funtion like this:

This will generate the necessary files for your function including the composer json and docker file to install this fdk.

Creating a PHP Function

Writing a PHP function is simply a matter of writing a handler function that you pass to the FDK to invoke each time your function is called.

Start by creating a php function with fn init:

This creates a simple hello world function in func.php:

The handler function takes the input that is sent to the function and returns a response. By default the input is treated as json which automatically converted to an array and the response is also an array (or json serializable object) which automatically converted to json. Using the FDK you don't have to worry about reading the http request or sending back the response. The FDK let's you focus on your function logic and not the mechanics.

Now run it!

You should see the following output:

Run it with input:

You should see the following output:

Now you have a basic running php function that you can modify and add what you want.

Function Context

Function invocation context details are available through an optional function argument. To receive a context object, simply add a second argument to your handler function. In the following example the callId is obtained from the context and included in the response message:

Run it:

You should see a similar output:

The context contains other context information about the request such as:

Handling input/output

By default the FDK will try to json decode the input, likewise by default the output of a function will be treated as a JSON object and converted using json_encode().

To change the handling of the input you can add an additional options parameter to fdk->handle that specifies the input handling strategy:

valid input modes are:

To change the output handling of your function from the default you should wrap the result value using a response decorator:

the available decorators are:

Using HTTP headers and setting HTTP status codes

You can read http headers passed into a function invocation using $ctx->getHeaderValue($key), this returns the first header value of the header matching key or you can use $ctx->getHeaders() or $ctx->getHeaderValues($key) methods as well.

Outbound headers and the HTTP status code can be modified in a similar way:

Examples

See examples here.


All versions of fn-fdk-php with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
react/http Version ^0.8.3
react/socket Version ^1.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tkotosz/fn-fdk-php contains the following files

Loading the files please wait ....