PHP code example of codingwithrk / firebase-crashlytics

1. Go to this page and download the library: Download codingwithrk/firebase-crashlytics 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/ */

    

codingwithrk / firebase-crashlytics example snippets


use Codingwithrk\FirebaseCrashlytics\Facades\FirebaseCrashlytics;

// Record a caught exception (non-fatal by default)
try {
    $this->riskyOperation();
} catch (\Throwable $e) {
    FirebaseCrashlytics::recordError($e);

    // or, if it should stand out as a fatal-style issue in the console
    FirebaseCrashlytics::recordError($e, fatal: true);
}

// recordException() is an alias for recordError(), matching the native SDKs' naming
FirebaseCrashlytics::recordException($e);

// Add a breadcrumb log, Crashlytics::isCrashlyticsCollectionEnabled();

// Manage unsent reports when automatic collection is disabled
if (FirebaseCrashlytics::checkForUnsentReports()) {
    FirebaseCrashlytics::sendUnsentReports();
    // or: FirebaseCrashlytics::deleteUnsentReports();
}

// Check whether the app crashed last time it ran
if (FirebaseCrashlytics::didCrashOnPreviousExecution()) {
    // e.g. show a "sorry, we crashed" message
}

// Force a real, unrecoverable crash to verify your integration end-to-end
FirebaseCrashlytics::crash();