@@ -12,14 +12,17 @@ exceptions, errors, and PHP fatral errors to Stackdriver Error Reporting.
1212
13131 . To use this sample, you must first [ enable the Stackdriver Error Reporting API] [ 0 ]
14141 . Next, ** Install dependencies** via [ Composer] ( http://getcomposer.org/doc/00-intro.md ) :
15- 1 . Run ` php composer.phar install --ignore-platform-reqs ` (if composer is installed locally) or ` composer install --ignore-platform-reqs `
15+ 1 . Run ` php composer.phar install ` (if composer is installed locally) or ` composer install `
1616 (if composer is installed globally).
1717 ``` sh
18- composer install --ignore-platform-reqs
18+ composer install
19+ ```
20+ 1. To use the [gRPC PHP Extension][php_grpc], which will be more performant than
21+ REST/HTTP,
22+ install and enable the gRPC extension using PECL:
23+ ` ` ` sh
24+ pecl install grpc
1925 ` ` `
20- 1. If the [gRPC PHP Extension][php_grpc] is enabled for your version of PHP,
21- install your dependencies without the ` --ignore-platform-reqs` flag. ** Note**
22- some samples in ` error_reporting.php` require gRPC.
23261. Create a service account in the [Service Account section of the Cloud Console][2]
24271. Download the JSON key file of the service account.
25281. Set ` GOOGLE_APPLICATION_CREDENTIALS` environment variable to point to that file.
@@ -36,41 +39,31 @@ Run the samples:
3639
3740` ` ` sh
3841php quickstart.php
39- Exception logged to Stackdriver Error Reporting
42+ Throwing a test exception. You can view the message at https://console.cloud.google.com/errors.
4043` ` `
4144
42- View [Stackdriver Error Reporting][1] in the Cloud Console to see the logged
43- exception.
45+ This example registers the Stackdriver exception handler using
46+ [PHP exception handlers][3]. View [Stackdriver Error Reporting][1] in the Cloud
47+ Console to see the logged exception.
4448
45- # Running error_reporting .php
49+ # Running src/report_error .php
4650
47- Run the sample:
48-
49- ` ` ` sh
50- $ php error_reporting.php report YOUR_PROJECT_ID
51- Reported an error to Stackdriver
52- ` ` `
51+ This sample shows how to report an error by creating a ` ReportedErrorEvent` . The
52+ ` ReportedErrorEvent` object gives you more control over how the error appears
53+ and the details associated with it.
5354
54- For an example of how to register the Stackdriver exception handler in your custom application, see
55- [src/register_exception_handler.php](src/register_exception_handler.php). You can test this out
56- using the samples:
55+ Run the sample:
5756
5857` ` ` sh
59- # Test registering an exception handler and then throwing a PHP Fatal Error
60- $ php error_reporting.php test-exception-handler YOUR_PROJECT_ID --fatal
61- Triggering a PHP Fatal Error by eval-ing a syntax error...
58+ $ php src/report_error.php YOUR_PROJECT_ID " This is a test message"
59+ Reported an exception to Stackdriver
6260` ` `
6361
64- For more granular control over your error reporting, and better performance, you can use the gRPC
65- library to throw errors. Follow the instructions to install and enable the
66- [gRPC PHP Extension][php_grpc]. Now run the gRPC example in ` error_reporting.php` :
67-
68- ` ` ` sh
69- $ php error_reporting.php report-grpc YOUR_PROJECT_ID
70- Reported an error to Stackdriver
71- ` ` `
62+ View [Stackdriver Error Reporting][1] in the Cloud Console to see the logged
63+ exception.
7264
7365[0]: https://console.cloud.google.com/flows/enableapi? apiid=clouderrorreporting.googleapis.com
7466[1]: https://console.cloud.google.com/errors
7567[2]: https://console.cloud.google.com/iam-admin/serviceaccounts/
76- [php_grpc]: http://cloud.google.com/php/grpc
68+ [3]: http://php.net/manual/en/function.set-exception-handler.php
69+ [php_grpc]: http://cloud.google.com/php/grpc
0 commit comments