PHPackages                             videlalvaro/azserverless - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. videlalvaro/azserverless

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

videlalvaro/azserverless
========================

"PHP Custom Handler for Azure Functions"

182.3k6[2 issues](https://github.com/videlalvaro/azserverless/issues)PHP

Since Nov 18Pushed 2y ago1 watchersCompare

[ Source](https://github.com/videlalvaro/azserverless)[ Packagist](https://packagist.org/packages/videlalvaro/azserverless)[ RSS](/packages/videlalvaro-azserverless/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Azure Serverless
================

[](#azure-serverless)

This projects provides a PHP [Custom Handler](https://docs.microsoft.com/azure/azure-functions/functions-custom-handlers?WT.mc_id=data-11039-alvidela) for Azure Functions.

Installation
------------

[](#installation)

In your composer.json add the following dependency:

```
"require": {
        "videlalvaro/azserverless": "*"
}
```

Then run:

```
composer update
```

Then start an Azure Functions project. In your `host.json` add the following:

```
"customHandler": {
    "description": {
        "defaultExecutablePath": "php",
        "arguments": [
            "-S",
            "0.0.0.0:%FUNCTIONS_CUSTOMHANDLER_PORT%",
            "vendor/videlalvaro/azserverless/bin/serverless.php"
        ]
    },
    "enableForwardingHttpRequest": false
},
```

See `host.sample.json` for an example of how this file should look like.

Finally, make copy the file `local.settings.sample.json` into your project and call it `local.settings.json`. Adapt the contents to include your connection strings in the `AzureWebJobsStorage` field.

Usage
-----

[](#usage)

In your Azure Functions project you will have one folder per serverless function.

To create a function called `HttpTrigger`, create a folder with the same name, then inside add two files: `function.json` and `index.php`. Here's their content:

```
{
  "disabled": false,
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "$return"
    }
  ]
}
```

And the corresponding index.php file:

```
