---
title: PHP
slug: brcli-php
docTags: 
createdAt: 2023-03-08T03:18:26.000Z
---

:::CodeblockTabs
```php
<?php

$args = array(
'"./BarcodeReaderCLI"',
'-type=code128',
'"https://wabr.inliteresearch.com/SampleImages/1d.pdf"',
'@./brcli-example.config' // Additional options and sources in configuration file
);

function doExec($cmd, &$stdout=null, &$stderr=null) {
    $proc = proc_open($cmd,[
        1 => ['pipe','w'],
        2 => ['pipe','w'],
    ],$pipes);
    $stdout = stream_get_contents($pipes[1]);
    fclose($pipes[1]);
    $stderr = stream_get_contents($pipes[2]);
    fclose($pipes[2]);
    return proc_close($proc);
}

$output = ""; $error = "";
$params = implode(" ", $args);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $params = '"' . $params . '"'; 

doExec($params, $output, $error);
if ($output != "") echo "STDOUT:\n $output";
if ($error != "") echo "STDERR:\n $error";
?>
```

brcli-example.config

```linux
# -silent
-type=code39
# image from URL
https://wabr.inliteresearch.com/SampleImages/1d.pdf
# image from local folder
./images/test.tif
```
:::

