Skip to content

Commit 01568d4

Browse files
author
Takashi Matsuo
authored
Add logging configuration to the symfony sample (GoogleCloudPlatform#556)
* Add logging configuration to the symfony sample * Updated app.yaml * Removed the ExceptionSubscriber which is no more needed * Added back src/AppBundle/EventSubscriber/ExceptionSubscriber.php * Updated the README * Dependency update * Removed composer.lock * Making sure our Error Reporting integration works * Have a separate section for creating a directory * Correct composer package for create-project
1 parent 9d2db49 commit 01568d4

File tree

8 files changed

+136
-956
lines changed

8 files changed

+136
-956
lines changed

appengine/flexible/symfony/README.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,16 @@ Before setting up Symfony on App Engine, you will need to complete the following
1717
Use composer to download Symfony Standard and its dependencies
1818

1919
```sh
20-
composer create-project symfony/symfony:^3.0
20+
composer create-project symfony/framework-standard-edition:^3.0
21+
```
22+
23+
# Integrate Stackdriver
24+
25+
Install some cloud libraries for Stackdriver integration
26+
27+
```sh
28+
cd /path/to/symfony
29+
composer require google/cloud-logging google/cloud-error-reporting
2130
```
2231

2332
## Copy over App Engine files
@@ -29,28 +38,22 @@ directory:
2938
# clone this repo somewhere
3039
git clone https://github.com/GoogleCloudPlatform/php-docs-samples /path/to/php-docs-samples
3140

32-
# copy the two files below to the root directory of your Symfony project
41+
# create a directory for the event subscriber
42+
mkdir -p /path/to/symfony/src/AppBundle/EventSubscriber
43+
44+
# copy the three files below to your Symfony project
3345
cd /path/to/php-docs-samples/appengine/flexible/symfony/
34-
cp ./{app.yaml,nginx-app.conf} /path/to/symfony
46+
cp app.yaml /path/to/symfony
47+
cp app/config/config_prod.yml /path/to/symfony/app/config
48+
cp src/AppBundle/EventSubscriber/ExceptionSubscriber.php \
49+
/path/to/symfony/src/AppBundle/EventSubscriber
3550
```
3651

37-
The two files needed are as follows:
52+
The three files needed are as follows:
3853

3954
1. [`app.yaml`](app.yaml) - The App Engine configuration for your project
40-
1. [`nginx-app.conf`](nginx-app.conf) - Nginx web server configuration needed for `Symfony`
41-
42-
Finally, you need to have a few scripts run after your application deploys.
43-
Add the following scripts to your project's `composer.json`:
44-
45-
```json
46-
{
47-
"scripts": {
48-
"post-install-cmd": [
49-
"chmod -R ug+w $APP_DIR/var"
50-
]
51-
}
52-
}
53-
```
55+
1. [`app/config/config_prod.yml`](app/config/config_prod.yml) - Symfony configurations for Stackdriver Logging
56+
1. [`src/AppBundle/EventSubscriber/ExceptionSubscriber.php`](src/AppBundle/EventSubscriber/ExceptionSubscriber.php) - Symfony configurations for Stackdriver Error Reporting
5457

5558
[1]: https://cloud.google.com/appengine/docs/flexible/
5659
[2]: https://console.cloud.google.com

appengine/flexible/symfony/app.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ env: flex
33

44
runtime_config:
55
document_root: web
6+
front_controller_file: app.php
7+
enable_stackdriver_integration: true
68

79
env_variables:
810
WHITELIST_FUNCTIONS: libxml_disable_entity_loader
11+
SYMFONY_ENV: prod
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
imports:
2+
- { resource: config.yml }
3+
4+
#doctrine:
5+
# orm:
6+
# metadata_cache_driver: apc
7+
# result_cache_driver: apc
8+
# query_cache_driver: apc
9+
10+
monolog:
11+
handlers:
12+
main:
13+
type: fingers_crossed
14+
action_level: debug # Choose whichever level you like
15+
handler: nested
16+
nested:
17+
type: service
18+
id: monolog_psr_batch_logger
19+
20+
services:
21+
# Monolog wrapper
22+
monolog_psr_batch_logger:
23+
class: Monolog\Handler\PsrHandler
24+
arguments: ['@psr_batch_logger']
25+
26+
# PsrBatchLogger
27+
psr_batch_logger:
28+
class: Google\Cloud\Logging\PsrLogger
29+
factory: ['Google\Cloud\Logging\LoggingClient', 'psrBatchLogger']
30+
arguments: ['app']

appengine/flexible/symfony/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"symfony/process": "^3.0",
77
"symfony/yaml": "^3.0",
88
"google/cloud-tools": "^0.6",
9+
"google/cloud-logging": "^1.9",
910
"paragonie/random_compat": " ^2.0"
1011
}
1112
}

0 commit comments

Comments
 (0)