buggregator / server

Buggregator is a lightweight, standalone server that offers a range of debugging features for PHP applications.
https://buggregator.dev/
Other
648 stars 23 forks source link

Inspector not working in Laravel app #99

Open binaryfire opened 9 months ago

binaryfire commented 9 months ago

Hi guys

It seems Inspector isn't working in Laravel. Sending to inspector.dev works correctly but not sending to Buggregator. I'm using the latest v1.0.0 Docker image.

The docs say this should be the config:

INSPECTOR_URL=http://inspector@127.0.0.1:8000
INSPECTOR_API_KEY=test
INSPECTOR_INGESTION_KEY=1test
INSPECTOR_ENABLE=true

But this line in the Inspector EventHandler suggests the uri should end with inspector?

I tried the above config and the following two configs with no luck:

INSPECTOR_URL=http://127.0.0.1:8000/api/inspector
INSPECTOR_API_KEY=test
INSPECTOR_INGESTION_KEY=1test
INSPECTOR_ENABLE=true
INSPECTOR_URL=http://127.0.0.1:8000/inspector
INSPECTOR_API_KEY=test
INSPECTOR_INGESTION_KEY=1test
INSPECTOR_ENABLE=true

Any ideas?

Thanks again!

butschster commented 9 months ago

Hi @binaryfire,

If you are using it inside a Docker container, it might be something like:

INSPECTOR_URL: http://inspector@buggregator:8000
INSPECTOR_API_KEY: test

Where buggregator is the container name.

Alternatively, the issue could be incorrect port mapping. If you map a port inside the container to your host server, like -p 8080:8000, then you should use port 8080.

binaryfire commented 9 months ago

Hi @butschster

Yeah actually I'm using the container name (buggregator). I used 127.0.0.1 in the examples above to avoid confusion :) I don't think that's the problem because these work perfectly:

RAY_HOST=ray@buggregator
RAY_PORT=8000

LOG_CHANNEL=socket
LOG_SOCKET_URL=buggregator:9913

VAR_DUMPER_FORMAT=server
VAR_DUMPER_SERVER=tcp://buggregator:9912

MAIL_MAILER=smtp
MAIL_HOST=buggregator
MAIL_PORT=1025

Also http-dumps to http://http-dump@bolt-buggregator:8000 work

But Inspector doesn't with either of these:

INSPECTOR_URL=http://inspector@buggregator:8000
INSPECTOR_API_KEY=test
INSPECTOR_INGESTION_KEY=1test
INSPECTOR_ENABLE=true

or

INSPECTOR_URL=http://inspector@buggregator:8000
INSPECTOR_API_KEY=test
butschster commented 9 months ago

Hmmm. I you the same settings in examples,

services:
  examples:
    build: "./docker/examples"
    environment:
      APP_ENV: production
      APP_KEY: xxx
      LOG_LEVEL: debug
      BROADCAST_DRIVER: log
      CACHE_DRIVER: array
      QUEUE_CONNECTION: sync
      DB_CONNECTION: sqlite
      DB_DATABASE: ":memory:"
      MAIL_HOST: buggregator
      MAIL_PORT: 1025
      MAIL_ENCRYPTION: null
      MAIL_FROM_ADDRESS: sender@site.com
      MAIL_FROM_NAME: sender
      RAY_HOST: ray@buggregator
      RAY_PORT: 8000
      VAR_DUMPER_SERVER: buggregator:9912
      SENTRY_LARAVEL_DSN: http://sentry@buggregator:8000/123
      LOG_SOCKET_URL: buggregator:9913
      LOG_SLACK_WEBHOOK_URL: http://buggregator:8000/slack
      INSPECTOR_URL: http://inspector@buggregator:8000
      INSPECTOR_API_KEY: test
      PROFILER_ENDPOINT: http://profiler@buggregator:8000
    ports:
      - 9020:8000
  buggregator:
    image: ghcr.io/buggregator/server:latest
binaryfire commented 9 months ago

Weird. Sentry isn't working for me either:

SENTRY_LARAVEL_DSN=http://sentry@buggregator:8000/1

Sending to sentry.io works, and I've had it working with Buggregator in other PHP apps with the same Docker setup. So I'm not sure what's going on with that one either. Could it be a problem with their new SDK? They released v4.0.0 last week which has some major changes: https://github.com/getsentry/sentry-laravel/releases

butschster commented 9 months ago

Weird. Sentry isn't working for me either:

SENTRY_LARAVEL_DSN=http://sentry@buggregator:8000/1

Sending to sentry.io works, and I've had it working with Buggregator in other PHP apps with the same Docker setup. So I'm not sure what's going on with that one either. Could it be a problem with their new SDK? They released v4.0.0 last week which has some major changes: https://github.com/getsentry/sentry-laravel/releases

In my opinion, no!

There is the same problem with Sentry on buggreagor.dev. It doesn't work. But locally inside Docker with the same settings, it works well. I'll try to dig deeper to discover the problem.

Could you try to clear the config cache?

I noticed that there are some main changes in the Laravel framework like this change in https://github.com/laravel/framework/blob/10.x/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php#L96 which disable setting symfony/var-dumper via the .env file. Now, there is only one way to set it up, for example, inside bootstrap/app.php like this:

$app = new Illuminate\Foundation\Application(
    $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
);

// var dumper setting
$_SERVER['VAR_DUMPER_FORMAT'] = 'server';
$_SERVER['VAR_DUMPER_SERVER'] = 'if-buggregator:9912';
binaryfire commented 9 months ago

Hi @butschster. Thanks for the update! Sentry is working in Laravel now 🎉

But Inspector still isn't for some reason. This is my config:

INSPECTOR_URL=http://inspector@buggregator:8000
INSPECTOR_API_KEY=test
INSPECTOR_INGESTION_KEY=1test
INSPECTOR_ENABLE=true

Connecting to inspector.dev works and requests show up in the dashboard so the inspector-apm/inspector-laravel package is working properly. Maybe there's an incompatibility somewhere?

butschster commented 9 months ago

Hi @binaryfire.

I'll try to cover your case with tests, and I'm confident everything will work fine. I'm currently working on the tests and addressing any incompatibilities