Barcode Reader CLI
Integration
PHP
PHP
brcli-example.config
1<?php
2
3$args = array(
4'"./BarcodeReaderCLI"',
5'-type=code128',
6'"https://wabr.inliteresearch.com/SampleImages/1d.pdf"',
7'@./brcli-example.config' // Additional options and sources in configuration file
8);
9
10function doExec($cmd, &$stdout=null, &$stderr=null) {
11 $proc = proc_open($cmd,[
12 1 => ['pipe','w'],
13 2 => ['pipe','w'],
14 ],$pipes);
15 $stdout = stream_get_contents($pipes[1]);
16 fclose($pipes[1]);
17 $stderr = stream_get_contents($pipes[2]);
18 fclose($pipes[2]);
19 return proc_close($proc);
20}
21
22$output = ""; $error = "";
23$params = implode(" ", $args);
24if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $params = '"' . $params . '"';
25
26doExec($params, $output, $error);
27if ($output != "") echo "STDOUT:\n $output";
28if ($error != "") echo "STDERR:\n $error";
29?>