PHP code example of rikstone / php-cpe

1. Go to this page and download the library: Download rikstone/php-cpe 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/ */

    

rikstone / php-cpe example snippets


use Rikstone\Cpe\Cpe22;
use Rikstone\Cpe\Part;

$cpe = (new Cpe22())
    ->setPart(Part::H)
    ->setVendor('dell')
    ->setProduct('inspiron')
    ->setVersion('8500');

echo $cpe;

use Rikstone\Cpe\Cpe23;
use Rikstone\Cpe\Part;

$cpe = (new Cpe23())
    ->setPart(Part::A)
    ->setVendor('f5')
    ->setProduct('nginx')
    ->setVersion('0.3.31');
//    ->setUpdate()
//    ->setEdition()
//    ->setLanguage()
//    ->setSwEdition()
//    ->setTargetSw()
//    ->setTargetHw()
//    ->setOther();

echo $cpe;
// cpe:2.3:a:f5:nginx:0.3.31:*:*:*:*:*:*:*

$cpe = Cpe22::fromString('cpe:/a:zoom:zoom_client_for_vdi:5.7.1');

echo $cpe->getVersion(); // 5.7.1

use Rikstone\Cpe\CpeConverter;
use Rikstone\Cpe\Cpe23;
use Rikstone\Cpe\Cpe22;

$source = Cpe22::fromString('cpe:/o:microsoft:windows_2000');

$cpe23 = (new Converter())->convert($source, Cpe23::class);

echo $cpe23; // cpe:2.3:o:microsoft:windows_2000:*:*:*:*:*:*:*:*

use Rikstone\Cpe\CpeConverter;
use Rikstone\Cpe\Cpe23;
use Rikstone\Cpe\Cpe22;

$source = Cpe23::fromString('cpe:2.3:a:zoom:zoom_client_for_vdi:5.7.1:*:*:*:*:*:*:*');

$cpe22 = (new Converter())->convert($source, Cpe22::class);

echo $cpe22; // cpe:/a:zoom:zoom_client_for_vdi:5.7.1
bash
composer