PHP code example of codingwithrk / package-info

1. Go to this page and download the library: Download codingwithrk/package-info 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 / package-info example snippets


use Codingwithrk\PackageInfo\Facades\PackageInfo;

$info = PackageInfo::getInfo();

if ($info) {
    echo $info->appName;        // "My App"
    echo $info->packageName;    // "com.example.myapp"
    echo $info->version;        // "1.2.3"
    echo $info->buildNumber;    // "42"
    echo $info->installerStore; // "com.android.vending" (Android) or "" (iOS)
}

$array = $info->toArray();
// ['appName' => '...', 'packageName' => '...', 'version' => '...', 'buildNumber' => '...', 'installerStore' => '...']

use Codingwithrk\PackageInfo\Events\PackageInfoRetrieved;
use Codingwithrk\PackageInfo\PackageInfoData;
use Native\Mobile\Attributes\OnNative;

#[OnNative(PackageInfoRetrieved::class)]
public function handlePackageInfoRetrieved(PackageInfoData $info): void
{
    $this->appName     = $info->appName;
    $this->version     = $info->version;
    $this->buildNumber = $info->buildNumber;
}