# Buggregator for local WordPress development
## Buggregator

0.  (You need [docker](https://www.docker.com/products/docker-desktop/))
1. Save the [`docker-compose.yml`](#file-docker-compose-yml) file.
2. Run `docker-compose up` in the same folder as the `docker-compose.yml` file.
	- Update buggregator by running `docker-compose pull`
4. Buggregator is at http://127.0.0.1:8000/#/

Learn more at https://docs.buggregator.dev/

## WordPress

> Make sure `WP_ENVIRONMENT_TYPE`is set to `local`. [Local](https://localwp.com/) (by WPEngine) does that by default.

### Log errors using WP Sentry
1. Install [WP Sentry](https://wordpress.org/plugins/wp-sentry-integration/). You don't have to activate it. We will [load it early](https://github.com/stayallive/wp-sentry/tree/v7.13.0?tab=readme-ov-file#loading-sentry-before-wordpress), to catch errors early.
2. In `wp-config.php` add:
```php
// NOTE: WP_ENVIRONMENT_TYPE must be defined and set to 'local'. Uncomment the line below if it's not set by the server
// define( 'WP_ENVIRONMENT_TYPE', 'local' );

if ( defined( 'WP_ENVIRONMENT_TYPE' ) && 'local' === WP_ENVIRONMENT_TYPE ) {
	define( 'WP_SENTRY_PHP_DSN', 'http://sentry@127.0.0.1:8000/1' );
	define( 'WP_SENTRY_ERROR_TYPES', E_ALL & ~E_NOTICE & ~E_USER_NOTICE );
	require_once __DIR__ . '/wp-content/plugins/wp-sentry-integration/wp-sentry.php';
}
```
Learn more at https://github.com/stayallive/wp-sentry/tree/v7.13.0?tab=readme-ov-file#usage

<details>
  <summary>Example: Exeception</summary>
<img width="878" alt="sentry" src="https://gist.github.com/assets/1649452/b70eb538-f521-45e2-b072-366127fc8a61">
</details>


### Dump stuff using ray
1. Install ray in your project using composer: `composer --dev require spatie/ray`
2. Copy [`ray.php`](#file-ray-php) to the root of your WordPress site 
3. Now you can [dump to buggregator](https://docs.buggregator.dev/config/ray.html), from your project,  using `\ray( $var );`


<details>
  <summary>Example: Variable dump</summary>
<img width="1037" alt="ray" src="https://gist.github.com/assets/1649452/951d92a8-f1c2-466b-9c44-414b5351c436">
</details>

### Send emails to Buggregator
Save [`mu-buggregator-smtp.php`](#file-mu-buggregator-smtp-php) in your `mu-plugins` folder

<details>
  <summary>Example: Email</summary>
<img width="727" alt="mail" src="https://gist.github.com/assets/1649452/a6c0ec2e-a632-4252-a20e-ebe878610cf1">
</details>