PhpDev.App
buggregator/server

buggregator/server

Stars: 102

Forks: 9

Pull Requests: 29

Issues: 31

Watchers: 8

Last Updated: 2023-09-11 10:25:23

Buggregator is a lightweight, standalone server that offers a range of debugging features for PHP applications.

License: Other

Languages: PHP, Shell, Dockerfile

https://buggregator.dev/

A server for debugging PHP applications and more.

Support me on Patreon Downloads Twitter

Cover image

Buggregator is a lightweight, standalone server that offers a range of debugging features for PHP applications. Built using the reliable Spiral Framework, the powerful NuxtJs, and the speedy RoadRunner under the hood. It's a versatile tool that can be run on multiple platforms via Docker.

Whether you're an experienced developer or just starting, Buggregator offers essential features like Xhprof, Symfony var-dumper, Monolog, Sentry, SMTP catcher, and Inspector that make it easy to identify and resolve issues. With no additional packages required, it's effortless to use, making it a must-have tool in your development arsenal.

Contents

  1. Features
  2. Installation
  3. Configuration
  4. Contributing
  5. License

Features

In this section, we'll explore the different features that Buggregator supports and how they can help you identify and resolve issues with your application.

1. Xhprof profiler

The Xhprof profiler is an essential feature of Buggregator that offers a lightweight and hierarchical profiling solution for PHP applications. It uses instrumentation to keep track of call counts and inclusive metrics for arcs in the dynamic callgraph of your program during the data collection phase. In the reporting and post-processing phase, the profiler computes exclusive metrics such as wall (elapsed) time, CPU time, and memory usage.

With the Xhprof profiler, you can easily identify performance bottlenecks and optimize your application's code for better efficiency. So, if you're looking to fine-tune your PHP application's performance, the Xhprof profiler is the perfect tool for the job.

xhprof

Installation

  1. Install Xhprof extension One of the way to install Xhprof is to use PECL package.
pear channel-update pear.php.net
pecl install xhprof
  1. Install the package

If you are using Spiral Framework you just need to install the spiral/profiler package.

composer require --dev spiral/profiler:^3.0

Configuration

After installing the package, you need to configure it. The package provides predefined environment variables to configure the profiler.

PROFILER_ENDPOINT=http://[email protected]:8000
PROFILER_APP_NAME=My super app

Note: Read more about package usage in the package documentation.

2. Symfony VarDumper server

Buggregator is fully compatible with the Symfony VarDumper component, which is an essential feature for debugging PHP applications. By default, the dump() and dd() functions output their contents in the same browser window or console terminal as your own application. This can be confusing at times, as it mixes the real output with the debug output.

With Buggregator, however, you can easily collect all the dumped data, making it simpler to identify and isolate issues. So, whether you're an experienced developer or just starting, the Symfony VarDumper server in Buggregator is an essential tool to have in your development arsenal.

var-dumper

Installation

composer require --dev symfony/var-dumper

Configuration

You should change dumper format to server for var-dumper component. There is a VAR_DUMPER_FORMAT env variable in the package to do it.

VAR_DUMPER_FORMAT=server
VAR_DUMPER_SERVER=127.0.0.1:9912 # Default value

via PHP

// Plain PHP
$_SERVER['VAR_DUMPER_FORMAT'] = 'server';
$_SERVER['VAR_DUMPER_SERVER'] = '127.0.0.1:9912';

3. Fake SMTP server for catching mail

Buggregator is more than just a PHP debugging tool. It also includes a powerful email testing feature that allows you to install and configure a local email server with ease.

For example, you can configure a local WordPress site to use Buggregator's SMTP server for email deliveries. This makes it effortless to test email functionality during the development phase, ensuring that everything works as expected before deployment. So, if you're looking for a reliable and easy-to-use email testing tool, Buggregator's fake SMTP server is the way to go.

smtp

Configuration

Env variables

// Spiral Framework or Symfony
MAILER_DSN=smtp://127.0.0.1:1025

# Laravel
MAIL_MAILER=smtp
MAIL_HOST=127.0.0.1
MAIL_PORT=1025

4. Compatible with Sentry reports

Buggregator offers seamless integration with Sentry reports, making it a reliable tool for local development. With it, you can easily configure your Sentry DSN to send data directly to the server, providing you with a lightweight alternative for debugging your application.

By using Buggregator to receive Sentry reports, you can identify and fix issues with your application before deploying it to production. This ensures that your application is robust and efficient, providing a smooth experience for your users. So, if you're looking for an easy and efficient way to receive Sentry reports during local development, Buggregator is the perfect tool for you.

sentry

Spiral Framework

Spiral Framework is supported via a native package. You can read about integrations on official site

SENTRY_DSN=http://[email protected]:8000/1

Laravel

Laravel is supported via a native package. You can read about integrations on official site

SENTRY_LARAVEL_DSN=http://[email protected]:8000/1

Other platforms

To report to Buggregator you’ll need to use a language-specific SDK. The Sentry team builds and maintains these for most popular languages.

You can find out documentation on official site


5. Monolog server

Buggregator comes with a powerful Monolog server that can receive logs from the popular monolog/monolog package via the \Monolog\Handler\SocketHandler handler. With this feature, you can easily track and analyze the logs generated by your PHP application, making it easier to identify issues and improve its overall performance.

By using Buggregator's Monolog server, you can gain valuable insights into your application's behavior and improve its overall efficiency. So, whether you're a seasoned developer or just starting, the Monolog server in Buggregator is a must-have tool for anyone serious about PHP development.

monolog

Spiral Framework

You can register socket handler for monolog via bootloader.

Bootloader example

<?php

declare(strict_types=1);

namespace App\Bootloader;

use Monolog\Formatter\JsonFormatter;
use Monolog\Handler\SocketHandler;
use Spiral\Boot\Bootloader\Bootloader;
use Spiral\Boot\EnvironmentInterface;
use Spiral\Monolog\Bootloader\MonologBootloader;

class LoggingBootloader extends Bootloader
{
    public function init(MonologBootloader $monolog, EnvironmentInterface $env): void
    {
        $handler = new SocketHandler($env->get('MONOLOG_SOCKET_HOST'), chunkSize: 10);
        $handler->setFormatter(new JsonFormatter(JsonFormatter::BATCH_MODE_NEWLINES));
        $monolog->addHandler('socket', $handler);
    }
}

Env variables

MONOLOG_DEFAULT_CHANNEL=socket
MONOLOG_SOCKET_HOST=127.0.0.1:9913

Laravel

Config

// config/logging.php
return [
    // ...
    'channels' => [
        // ...
        'socket' => [
            'driver' => 'monolog',
            'level' => env('LOG_LEVEL', 'debug'),
            'handler' => \Monolog\Handler\SocketHandler::class,
            'formatter' => \Monolog\Formatter\JsonFormatter::class,
            'handler_with' => [
                'connectionString' => env('LOG_SOCKET_URL', '127.0.0.1:9913'),
            ],
        ],
    ],
];

Env variables

LOG_CHANNEL=socket
LOG_SOCKET_URL=127.0.0.1:9913

Other PHP frameworks

Install monolog

composer require monolog/monolog
<?php

use Monolog\Logger;
use Monolog\Handler\SocketHandler;
use Monolog\Formatter\JsonFormatter;

// create a log channel
$log = new Logger('buggregator');
$handler = new SocketHandler('127.0.0.1:9913');
$handler->setFormatter(new JsonFormatter());
$log->pushHandler($handler);

// Send records to the Buggregator
$log->warning('Foo');
$log->error('Bar');

6. Compatible with Inspector reports

Buggregator is also compatible with Inspector reports, providing you with a lightweight alternative for local development. With it, you can easily configure your Inspector client URL to send data directly to the server, making it easier to identify and fix issues during the development phase.

inspector

Laravel settings

Laravel is supported via a native package. You can read about integrations on official site

INSPECTOR_URL=http://[email protected]:8000
INSPECTOR_API_KEY=test
INSPECTOR_INGESTION_KEY=1test
INSPECTOR_ENABLE=true

Other platforms

For PHP you can use inspector-apm/inspector-php package.

use Inspector\Inspector;
use Inspector\Configuration;

$configuration = new Configuration('YOUR_INGESTION_KEY');
$configuration->setUrl('http://[email protected]:8000');
$inspector = new Inspector($configuration);

// ...

To report to Buggregator you’ll need to use a language-specific SDK. The Inspector team builds and maintains these for most popular languages.

Note: You can find out documentation on official site

7. HTTP Requests dump server

It's an indispensable tool that simplifies the process of capturing, analyzing, and debugging HTTP requests in their applications. With the HTTP Requests Dump Server, developers can effortlessly capture all the relevant request data and gain valuable insights. They can dive deep into the captured requests, examine their contents, and pinpoint any issues or anomalies that might be affecting their application's performance.

Simply start the server and send your requests to the http://[email protected]:8000 URL, it will not only capture the URI segments but also gather additional details such as the request headers, cookies, POST data, query strings, and any uploaded files.

For instance, let's say you have a POST request: http://[email protected]:8000/user/3/update. In this case, server will intercept the request and capture all the relevant information. It will then display the dumped data, allowing you to examine the request details, including the URI segments (user/3/update in this example).

HTTP Requests dump server


8. Spatie Ray debug tool

Buggregator is compatible with spatie/ray package. The Ray debug tool supports PHP, Ruby, JavaScript, TypeScript, NodeJS, Go and Bash applications. After installing one of the libraries, you can use the ray function to quickly dump stuff. Any variable(s) that you pass will be sent to the Buggregator.

Ray debug tool

Supported features: Simple data, Labels, Caller, Trace, Counter, Class name of an object, Measure, Json, Xml, Carbon, File, Table, Image, Html, Text, Notifications, Phpinfo, Exception, Show queries, Count queries, Show events, Show jobs, Show cache, Model, Show views, Markdown, Collections, Env, Response, Request, Application log, Show Http client requests

Laravel settings

Please make sure ray.php config published to the project root.

You can run an artisan command to publish it in to the project root.

php artisan ray:publish-config

Env variables

[email protected]  # Ray server host (Current HTTP buggregator port)
RAY_PORT=8000           # Ray server port

Framework agnostic PHP

In framework agnostic projects you can use this template as the ray config file.

<?php
// Save this in a file called "ray.php"

return [
    /*
    * This settings controls whether data should be sent to Ray.
    */
    'enable' => true,

    /*
     *  The host used to communicate with the Ray app.
     */
    'host' => '[email protected]',

    /*
     *  The port number used to communicate with the Ray app.
     */
    'port' => 8000,

    /*
     *  Absolute base path for your sites or projects in Homestead, Vagrant, Docker, or another remote development server.
     */
    'remote_path' => null,

    /*
     *  Absolute base path for your sites or projects on your local computer where your IDE or code editor is running on.
     */
    'local_path' => null,

    /*
     * When this setting is enabled, the package will not try to format values sent to Ray.
     */
    'always_send_raw_values' => false,
];

You can find out more information about installation and configuration on official site


Technological stack

Installation

Docker image

To run Buggregator using docker, you can use the docker image available on Github Packages

Latest stable release

To run the latest stable release, use the following command:

docker run --pull always -p 8000:8000 -p 1025:1025 -p 9912:9912 -p 9913:9913 ghcr.io/buggregator/server:latest

Latest dev release

To run the latest development release, use the following command:

docker run --pull always -p 8000:8000 -p 1025:1025 -p 9912:9912 -p 9913:9913 ghcr.io/buggregator/server:dev

Note: You can omit --pull always argument if your docker-compose doesn't support it.

Specific version

To run a specific version of Buggregator, use the following command:

docker run -p 8000:8000 -p 1025:1025 -p 9912:9912 -p 9913:9913 ghcr.io/buggregator/server:v1.00

Note: You can omit unused ports if you only use, for example, symfony/var-dumper.

docker run --pull always -p 9912:9912 ghcr.io/buggregator/server:latest

Using buggregator with docker compose

You can also use Buggregator with Docker Compose. Add the following service definition to your docker-compose.yml file:

services:
    # ...

    buggregator:
        image: ghcr.io/buggregator/server:dev
        ports:
            - 8000:8000
            - 1025:1025
            - 9912:9912
            - 9913:9913

After that, you can open http://127.0.0.1:8000 in your browser and start collecting dumps from your application.

Enjoy!


Contributing

We enthusiastically invite you to contribute to Buggregator Server! Whether you've uncovered a bug, have innovative feature suggestions, or wish to contribute in any other capacity, we warmly welcome your participation. Simply open an issue or submit a pull request on our GitHub repository to get started.

We use the help wanted label to categorize all issues that would benefit from your help in the repository.

Why Should Developers Contribute to Open Source?

Open source contributions, such as to Buggregator Server, present a unique and rewarding opportunity, especially for junior developers.

Here are a few reasons why you should consider contributing:

  1. Experiment with New Technologies: Open source projects can expose you to technologies and frameworks you might not encounter in your daily job. It's an excellent opportunity to learn and try out new things.
  2. Expand Your Network: Collaborating on open source projects connects you with a global community of developers. You can learn from their experiences, and they can learn from yours.
  3. Improve Your Résumé: Potential employers often value open source contributions. They demonstrate initiative, technical competency, and the ability to work collaboratively
  4. Learn Best Practices: Code reviews and feedback in open source projects are valuable learning tools. They expose you to different perspectives and ways to improve your code.
  5. Create Impact: Your contributions can help others and make a meaningful impact on the project. The feeling of seeing your code being used by others is immensely satisfying.

Remember, every great developer was once a beginner. Contributing to open source projects is a step in your journey to becoming a better developer. So, don't hesitate to jump in and start contributing!

We appreciate any contributions to help make Buggregator better!*

Backend part

Server requirements

  1. PHP 8.1

Installation

  1. Clone repository git clone https://github.com/buggregator/server.git
  2. Install backend dependencies composer install
  3. Download RoadRunner binary vendor/bin/rr get-binary
  4. Install frontend dependencies cd frontend && yarn install
  5. Install Centrifugo server cd bin && ./get-binaries.sh
  6. Run RoadRunner server ./rr serve

License

Buggregator is open-sourced software licensed under the BSD-4 License.