PHP 7.3 v2 Specialization (#1110)
* Added support for PHP 7.3 v2 Specialization * Add builder dockerfile for PHP7 * Support mcrypt in PHP 7.3
This commit is contained in:
committed by
Ta-Ching Chen
parent
38b8cfaa0a
commit
f104f0b46b
@@ -0,0 +1,69 @@
|
||||
This is an example of creating a deployment package with multiple
|
||||
files including external libraries via composer.
|
||||
|
||||
### Create an environment
|
||||
|
||||
```
|
||||
fission env create --name php --image fission/php-env:latest --builder fission/php-builder:latest --version 2
|
||||
```
|
||||
|
||||
### Create a zip file with all your files
|
||||
|
||||
```
|
||||
zip -r multifile.zip . -i *.php *.txt composer.json
|
||||
```
|
||||
|
||||
### Create a package
|
||||
```
|
||||
fission package create --sourcearchive multifile.zip --env php
|
||||
```
|
||||
This command will print the created package. We will use it in the next step.
|
||||
|
||||
|
||||
### Create a function
|
||||
|
||||
Since there are multiple files, you have to specify an _entrypoint_ to
|
||||
for the function. Its format is `<file path>::<function name>`. In our
|
||||
example, that's `handlers/FileReader.php::execute`, to run function `execute` in `handlers/FileReader.php`.
|
||||
|
||||
```
|
||||
fission function create --name multifile --env php --pkg <created-pkg-name> --entrypoint "handlers/FileReader.php::execute"
|
||||
```
|
||||
|
||||
### Test it
|
||||
|
||||
```
|
||||
fission function test --name multifile
|
||||
```
|
||||
|
||||
You should see the "Hello, world" message.
|
||||
|
||||
|
||||
## Updating the function
|
||||
|
||||
### Edit a file
|
||||
|
||||
```
|
||||
echo "I said hellooooo!" > message.txt
|
||||
```
|
||||
|
||||
### Update the deployment package
|
||||
|
||||
```
|
||||
zip -r multifile.zip . -i *.php *.txt composer.json
|
||||
```
|
||||
|
||||
### Update the package
|
||||
|
||||
```
|
||||
fission package update --name <created-pkg-name> --sourcearchive multifile.zip --env php
|
||||
```
|
||||
|
||||
### Test it
|
||||
|
||||
```
|
||||
fission function test --name multifile
|
||||
```
|
||||
|
||||
You should now see your new, edited message.
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "example/php7",
|
||||
"description": "Example for php7 environment",
|
||||
"require": {
|
||||
"psr/log": "^1.1",
|
||||
"psr/http-message": "^1.0"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Alberto Lopez",
|
||||
"email": "alberto.lopez.benito@gmail.com"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
function execute($context)
|
||||
{
|
||||
/** @var ResponseInterface $response */
|
||||
$response = $context["response"];
|
||||
/** @var LoggerInterface $logger */
|
||||
$logger = $context["logger"];
|
||||
$response->getBody()->write(file_get_contents(__DIR__ . '/message.txt'));
|
||||
$logger->debug('File read: example.txt');
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
I said hellooooo!
|
||||
Reference in New Issue
Block a user