Skip to content

Commit aa278b3

Browse files
committed
add docs for serverles and rect versions
1 parent 6b1d37b commit aa278b3

File tree

5 files changed

+133
-1
lines changed

5 files changed

+133
-1
lines changed

docs/_sidebar.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
* [Queues](https://queue.antidotfw.io/)
1515
* [Symfony config translator](https://sf-config.antidotfw.io/)
1616
* [Template Renderer](https://template.antidotfw.io/)
17+
* [React Framework](https://react.antidotfw.io/)

docs/framework/_sidebar.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* **Docs**
33
* [Getting Started](/framework/getting-started.md "Getting started guide for Antidot Framework")
44
* [Running Application](/framework/running-application.md "Running guide for Antidot Framework")
5+
* [Serverless](/framework/serverless.md "Serverless guide for Antidot Framework using Bref.sh")
56
* [Routing](/framework/routing.md)
67
* [Templating](/framework/templating.md)
78
* [Persistence Layer](/framework/persitence.md)

docs/framework/getting-started.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Installation
44

5+
### Standard Version
6+
57
> https://github.com/antidot-framework/antidot-starter
68
79
Using [composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos) package manager
@@ -10,6 +12,14 @@ Using [composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix
1012
composer create-project antidot-fw/antidot-framework-starter project-name
1113
````
1214

15+
### ReactPHP Version
16+
17+
> https://github.com/antidot-framework/antidot-starter
18+
19+
````bash
20+
composer create-project antidot-fw/reactive-starter project-name
21+
````
22+
1323
## File Structure
1424

1525
````

docs/framework/running-application.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,123 @@ php -S 127.0.0.1:8000 -t public
1111
````
1212
![running built in server](/../images/php-built-in-server.jpg)
1313

14+
## Running Antidot Framework in AWS Lambda using Bref
15+
16+
This guide helps you run Antidot framework applications on AWS Lambda using Bref.
17+
18+
A demo application is available on GitHub at
19+
[github.com/antidot-framework/antidot-bref-lambda-demo](https://github.com/antidot-framework/antidot-bref-lambda-demo).
20+
21+
### Setup
22+
23+
Assuming you are in an existing [Antidot Framework project](https://github.com/antidot-framework/antidot-starter), let's
24+
install Bref via Composer:
25+
26+
```
27+
composer require bref/bref
28+
```
29+
30+
Then let's create a `serverless.yml` configuration file (at the root of the project) optimized for Antidot Framework:
31+
32+
```yaml
33+
service: bref-demo-antidot
34+
35+
provider:
36+
name: aws
37+
region: us-east-1
38+
runtime: provided.al2
39+
environment:
40+
# Your project environment variables
41+
# APP_ENV: prod
42+
43+
plugins:
44+
- ./vendor/bref/bref
45+
46+
package:
47+
exclude:
48+
- node_modules/**
49+
- tests/**
50+
51+
functions:
52+
website:
53+
handler: public/index.php
54+
timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds)
55+
layers:
56+
# - ${bref:layer.php-74-fpm}
57+
- ${bref:layer.php-80-fpm}
58+
events:
59+
- http: 'ANY /'
60+
- http: 'ANY /{proxy+}'
61+
console:
62+
handler: bin/console
63+
timeout: 120 # in seconds
64+
layers:
65+
# - ${bref:layer.php-74} # PHP
66+
- ${bref:layer.php-80} # PHP
67+
- ${bref:layer.console} # The "console" layer
68+
```
69+
70+
Now we still have a few modifications to do on the application to make it compatible with AWS Lambda.
71+
72+
Since [the filesystem is readonly](https://bref.sh/docs/environment/storage.html) except for `/tmp` we need to customize where the cache
73+
is stored in the `config/config.php` and `config/cli-config.php` files.
74+
75+
```php
76+
<?php
77+
// config/config.php
78+
$cacheConfig = [
79+
'config_cache_path' => dirname('../tmp/cache') . '/config-cache.php',
80+
];
81+
...
82+
```
83+
84+
```php
85+
<?php
86+
// config/cli-config.php
87+
...
88+
$cacheConfig = [
89+
'cli_config_cache_path' => dirname('../tmp/cache') . 'cli-config-cache.php',
90+
];
91+
...
92+
```
93+
94+
### Deploy
95+
96+
Your application is now ready to be deployed. Follow [the deployment guide](https://bref.sh/docs/deploy.html).
97+
98+
### Console
99+
100+
As you may have noticed, we define a function of type "console" in `serverless.yml`. That function is using the [Console runtime](https://bref.sh/docs/runtimes/console.html), which lets us run the Antidot Framework Console on AWS Lambda.
101+
102+
To use it follow [the "Console" guide](https://bref.sh/docs/runtimes/console.html).
103+
104+
### Logs
105+
106+
We need to configure Monolog to log into `stderr` as well:
107+
108+
```yaml
109+
# config/services/dependencies.prod.yaml
110+
monolog:
111+
handlers:
112+
default:
113+
type: 'stream'
114+
options:
115+
stream: 'php://stderr'
116+
level: 400
117+
```
118+
119+
### Environment variables
120+
121+
You can define your environment variables in `serverless.yml` in the [Globals section](https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst):
122+
123+
```yaml
124+
Globals:
125+
Function:
126+
Environment:
127+
Variables:
128+
APP_ENV: prod
129+
```
130+
131+
The secrets (e.g. database passwords) must however not be committed in this file.
132+
133+
To learn more about all this, read the [environment variables documentation](https://bref.sh/docs/environment/variables.html).

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8">
55
<title>Antidot Framework Docs</title>
66
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
7-
<meta name="description" content="Description">
7+
<meta name="description" content="PHP full featured micro-framework designed to allow you to write 100% framework agnostic code.">
88
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
99
<meta name="twitter:card" content="summary" />
1010
<meta name="twitter:site" content="@antidotframewo1" />

0 commit comments

Comments
 (0)