creemedia/cakebrake4

CakePHP-4.x Airbrake plugin

Installs: 31 141

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:cakephp-plugin

1.0.2 2020-10-28 16:32 UTC

This package is auto-updated.

Last update: 2024-04-27 04:46:19 UTC


README

CakePHP 4 Airbrake plugin

Inspiration

This packages is inspired by not maintained CakePHP 3 package hrisShick/AirbrakeCake

Requirements

This plugins has been developed for cakephp >=4.0 and PHP >=7.2

How do I get set up?

Add in Composer file:

composer require creemedia/cakebrake4

create <PROJECT_NAME>/config/airbrake_options.php

READ:

add options like:

return [
  'AirbrakeOptions' => [
    'project_id' => '<PROJECT_ID>',
    'project_api_key' => '<PROJECT_KEY>',
    // deploy config
    'environment' => '',
    'revision' => '',
    'username' => '',
    'repository' => '', // change to your own, example [https://github.com/airbrake/airbrake;]
    'revision' => '', // example exec('git rev-parse HEAD'),
  ]
];

You can add revision to track different versions of your application.

Application.php

Load plugin in bootstrap() method before call parent::bootstrap()

    public function bootstrap(): void
    {
        $this->addPlugin('Creemedia/CakeBrake4');

        // Call parent to load bootstrap from files.
        parent::bootstrap();
		// ...
	}

bootstrap.php

If you are loading the environment property in your airbrake_options.php from another config file, load airbrake_options afterwards.

	Configure::load('airbrake_options', 'default');

	$isCli = php_sapi_name() === 'cli';
	if ($isCli) {
		(new ConsoleErrorHandler(Configure::read('Error')))->register();
	} else {
		if (!Configure::read('debug')) {
			(new \Creemedia\CakeBrake4\Error\AirbrakeHandler(Configure::read('Error')))->register();
		} else {
			(new ErrorHandler(Configure::read('Error')))->register();
		}
	}

DeployTracking command.

	bin/cake airbrake_deploy_tracking

Contribution guidelines

  • Writing tests
  • Code review
  • Other guidelines