# Error in APM PHP agent

**URL:** <https://discuss.elastic.co/t/error-in-apm-php-agent/265999>\
**Category:** APM\
**Tags:** php\
**Created:** [March 2, 2021, 5:59pm UTC](https://discuss.elastic.co/t/error-in-apm-php-agent/265999 "2021-03-02T17:59:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rgb3](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rgb3](https://discuss.elastic.co/u/rgb3)\
**Post date:** [March 2, 2021, 5:59pm UTC](https://discuss.elastic.co/t/error-in-apm-php-agent/265999/1 "2021-03-02T17:59:44Z")

</div>

**Kibana version** : 7.11.1

**Elasticsearch version** : 7.11.1

**APM Server version** : 7.11.1

**APM Agent language and version** : PHP 1.0 beta

**Browser version** : N/A, but Firefox 86.0

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**: dpkg

**Fresh install or upgraded from other version?** fresh

**Is there anything special in your setup?**

Not that i can think of. I'm using PHP 7.4 FPM and CLI. Here are the relevant php.ini entries:

```auto
extension=/opt/elastic/apm-agent-php/extensions/elastic_apm-20190902.so
elastic_apm.bootstrap_php_part_file=/opt/elastic/apm-agent-php/src/bootstrap_php_part.php
elastic_apm.server_url=http://<redacted>:8200
elastic_apm.service_name="Nextcloud"

```

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:

APM runs fine for a few minutes, then an error sequence appears repeatedly in logs (see below).

Configuration is Nextcloud running on Apache 2 with PHP 7.4 FPM. Stack otherwise runs fine.

**Steps to reproduce** :

1. add agent extension to php.ini file
2. restart php7.4-fpm service
3. wait a few minutes, then exercise website

**Errors in browser console (if relevant)**: none

**Provide logs and/or server output (if relevant)**:

```auto
   12:03:56.142

    apache.error

    [apache][error] AH01071: Got error 'PHP message: PHP Notice: Undefined variable: _SERVER in /opt/elastic/apm-agent-php/src/ElasticApm/Impl/AutoInstrument/TransactionForExtensionRequest.php on line 98'

    12:04:06.000

    system.syslog

    Elastic APM PHP Tracer [PID: 8217] 2021-03-02 12:04:06.124424-05:00 [CRITICAL] [Bootstrap] [BootstrapStageLogger.php:91] [bootstrap] One of the steps in bootstrap sequence let a throwable escape. TypeError: Argument 2 passed to Elastic\Apm\Impl\Util\ArrayUtil::getValueIfKeyExistsElse() must be of the type array, null given, called in /opt/elastic/apm-agent-php/src/ElasticApm/Impl/AutoInstrument/TransactionForExtensionRequest.php on line 98#012Stack trace:#012#0 /opt/elastic/apm-agent-php/src/ElasticApm/Impl/AutoInstrument/TransactionForExtensionRequest.php(98): Elastic\Apm\Impl\Util\ArrayUtil::getValueIfKeyExistsElse()#012#1 /opt/elastic/apm-agent-php/src/ElasticApm/Impl/AutoInstrument/TransactionForExtensionRequest.php(46): Elastic\Apm\Impl\AutoInstrument\TransactionForExtensionRequest->discoverHttpName()#012#2 /opt/elastic/apm-agent-php/src/ElasticApm/Impl/AutoInstrument/TransactionForExtensionRequest.php(41): Elastic\Apm\Impl\AutoInstrument\TransactionForExtensionRequest->beginTransaction()#012#3 /opt/elastic/apm-agent-php/src/ElasticApm/Impl/AutoInstrument/PhpPartFacade.php(52): Elastic\Apm\Impl\AutoInstrument\TransactionForExtensionRequest->__construct()#012#4 /opt/elastic/apm-agent-php/src/ElasticApm/Impl/AutoInstrument/PhpPartFacade.php(86): Elastic\Apm\Impl\AutoInstrument\PhpPartFacade->__construct()#012#5 [internal function]: Elastic\Apm\Impl\AutoInstrument\PhpPartFacade::bootstrap()#012#6 {main}

    12:04:06.000

    system.syslog

    Elastic APM PHP Tracer [PID: 8217] 2021-03-02 12:04:06.125019-05:00 [CRITICAL] [C-to-PHP] [tracer_PHP_part.c:62] [bootstrapTracerPhpPart] \Elastic\Apm\Impl\AutoInstrument\PhpPartFacade::bootstrap failed (returned false). See log for more details.

    12:04:06.000

    system.syslog

    Elastic APM PHP Tracer [PID: 8217] 2021-03-02 12:04:06.154411-05:00 [NOTICE] [Bootstrap] [BootstrapStageLogger.php:158] [shutdown] Shutdown sequence is invoked even though singleton instance is not created (probably because bootstrap sequence failed)

```

---

<div class="post-metadata">

**Author:** ![Sergey\_Kleyman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sergey_kleyman/32/39333_2.png) [@Sergey\_Kleyman](https://discuss.elastic.co/u/Sergey_Kleyman)\
**Post date:** [March 8, 2021, 8:04am UTC](https://discuss.elastic.co/t/error-in-apm-php-agent/265999/2 "2021-03-08T08:04:14Z")

</div>

Hi @rgb3 - welcome to the forum!

It seems the issue is the same one as the one [here](https://github.com/elastic/apm-agent-php/issues/77). Can you please try the workaround proposed at [https://odd.blog/2015/02/12/php-notice-undefined-variable-\_server-in/](https://odd.blog/2015/02/12/php-notice-undefined-variable-_server-in/) (which is setting `auto_globals_jit` to `off` in `php.ini`)?

---

<div class="post-metadata">

**Author:** ![rgb3](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rgb3](https://discuss.elastic.co/u/rgb3)\
**Post date:** [March 8, 2021, 10:21pm UTC](https://discuss.elastic.co/t/error-in-apm-php-agent/265999/3 "2021-03-08T22:21:07Z")

</div>

Hi, Sergey, thanks for the welcome and the tip! Seems to have worked so far. Will keep this channel posted.

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 29, 2021, 6:21pm UTC](https://discuss.elastic.co/t/error-in-apm-php-agent/265999/4 "2021-03-29T18:21:34Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
