1. Go to this page and download the library: Download codekandis/sentry-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
declare( strict_types = 1 );
namespace Vendor\Project;
use CodeKandis\SentryClient\Configurations\SentryClientConfigurationInterface;
class SentryClientConfiguration implements SentryClientConfigurationInterface
{
public function getDsn(): string
{
return 'dsn';
}
/**
* ...
*/
}
$sentryClientConfiguration = new SentryClientConfiguration();
declare( strict_types = 1 );
namespace Vendor\Project;
use CodeKandis\SentryClient\Configurations\SentryClientConfiguration;
use CodeKandis\SentryClient\SentryClient;
use const E_ALL;
$sentryClient = new SentryClient(
( new SentryClientConfiguration() )
->setDsn( 'dsn' )
->setErrorTypes( E_ALL )
->setDisplayErrors( true )
);
declare( strict_types = 1 );
namespace Vendor\Project;
use CodeKandis\SentryClient\Configurations\SentryClientConfiguration;
use CodeKandis\SentryClient\SentryClient;
use CodeKandis\SentryClient\Severities;
( new SentryClient( new SentryClientConfiguration() ) )
->captureMessage(
'This is a message.',
Severities::INFO,
[
'some' => 'context'
],
[
'some tag',
'another tag'
],
[
'id' => 'some username',
'ip_address' => '42.42.42.42'
]
);
declare( strict_types = 1 );
namespace Vendor\Project;
use CodeKandis\SentryClient\Configurations\SentryClientConfiguration;
use CodeKandis\SentryClient\SentryClient;
use CodeKandis\SentryClient\Severities;
( new SentryClient( new SentryClientConfiguration() ) )
->captureLastError(
Severities::ERROR,
[
'some' => 'context'
],
[
'some tag',
'another tag'
],
[
'id' => 'some username',
'ip_address' => '42.42.42.42'
]
);
declare( strict_types = 1 );
namespace Vendor\Project;
use CodeKandis\SentryClient\Configurations\SentryClientConfiguration;
use CodeKandis\SentryClient\SentryClient;
use CodeKandis\SentryClient\Severities;
use Exception;
( new SentryClient( new SentryClientConfiguration() ) )
->captureThrowable(
new Exception( 'This is an exception' ),
Severities::FATAL,
[
'some' => 'context'
],
[
'some tag',
'another tag'
],
[
'id' => 'some username',
'ip_address' => '42.42.42.42'
]
);
declare( strict_types = 1 );
namespace Vendor\Project;
use CodeKandis\SentryClient\Configurations\SentryClientConfiguration;
use CodeKandis\SentryClient\SentryClient;
( new SentryClient( new SentryClientConfiguration() ) )
->register();
declare( strict_types = 1 );
namespace Vendor\Project;
use CodeKandis\SentryClient\Configurations\SentryClientConfiguration;
use CodeKandis\SentryClient\SentryClient;
use Exception;
use Throwable;
use function set_error_handler;
use function set_exception_handler;
use function trigger_error;
set_error_handler(
function ( int $level, string $message )
{
echo 'Error handler: ' . $message . "\n";
}
);
set_exception_handler(
function ( Throwable $exception )
{
echo 'Exception handler: ' . $exception->getMessage() . "\n";
}
);
( new SentryClient( new SentryClientConfiguration() ) )
->register();
trigger_error( 'An error occured.' ); // outputs `Error handler: An error occured.`
throw new Exception( 'An exception occured.' ); // outputs `Exception handler: An exception occured.`
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.