|
| 1 | +# cli-barcode PHP |
| 2 | +Generates awesome barcodes from CLI using PHP |
| 3 | +This script uses @picqer's [php-barcode-generator](https://github.com/picqer/php-barcode-generator) to generate barcodes from the command line. |
| 4 | +For command line parsing @ulrichsg's [getopt-php](https://github.com/ulrichsg/getopt-php) is used. |
| 5 | + |
| 6 | +The credits should go mostly to them, since this is a very simple script that uses what they have made. |
| 7 | + |
| 8 | +## How to install |
| 9 | +The vendor folder is included since I want to be able to just download this package and install it. |
| 10 | + |
| 11 | +You should download the zip or tarball and extract it / move it to where you want it to be instaled. |
| 12 | + |
| 13 | +Then you can run: |
| 14 | +``` |
| 15 | +./barcode.php --create-bash |
| 16 | +``` |
| 17 | +To recreate the `barcode` file with the full path to your installation. |
| 18 | + |
| 19 | +At this point you can run: |
| 20 | +``` |
| 21 | +sudo make install |
| 22 | +``` |
| 23 | +To copy the bash executable to `/usr/local/bin`. |
| 24 | +You will need to have `make` installed for this. |
| 25 | + |
| 26 | +## Generating barcodes |
| 27 | +Usage is pretty straight forward. |
| 28 | +#####There are 4 required parameters |
| 29 | +1. Encoding (barcode type) |
| 30 | +2. Output format (jpg, svg, etc) |
| 31 | +3. Barcode string (will become the barcode) |
| 32 | +4. Output file (where to save it) |
| 33 | + |
| 34 | +#####Apart from that you get a few optional parameters |
| 35 | +* Width factor for the bars (defaults to 2) |
| 36 | +* Height of the bars (defaults to 30) |
| 37 | +* Color of the bars (defaults to black) |
| 38 | + |
| 39 | +I find the default settings for these very optimal, since there is usually no problem on resising the barcodes generated. |
| 40 | + |
| 41 | +## Help Information from cli |
| 42 | +``` |
| 43 | +$ barcode --help |
| 44 | +Usage: barcode -e <encoding> -f <output_format> [options] <barcode string> <output file> |
| 45 | +Options: |
| 46 | + -e, --encoding <bar-type> Barcode encoding type selection |
| 47 | + -f, --format <file-type> Output format for the barcode |
| 48 | + -w, --width <points> Width factor for bars to make wider, defaults to 2 |
| 49 | + -h, --height <points> Total height of the barcode, defaults to 30 |
| 50 | + -c, --color <hex-color> Hex code of the foreground color, defaults to black |
| 51 | + -v, --verbose Display extra information |
| 52 | + -q, --quiet Supress all messages |
| 53 | + --help Help Information, including encodings and formats |
| 54 | + --version Display version information and exits |
| 55 | +
|
| 56 | +Required Options and Parameters: |
| 57 | + -e <encoding> |
| 58 | + -f <output format> |
| 59 | + <input string> |
| 60 | + <output file> |
| 61 | +
|
| 62 | +Output Formats: |
| 63 | + HTML |
| 64 | + JPG |
| 65 | + PNG |
| 66 | + SVG |
| 67 | +
|
| 68 | +Encodings: |
| 69 | + CODABAR |
| 70 | + CODE_11 |
| 71 | + CODE_128 |
| 72 | + CODE_128_A |
| 73 | + CODE_128_B |
| 74 | + CODE_128_C |
| 75 | + CODE_39 |
| 76 | + CODE_39E |
| 77 | + CODE_39E_CHECKSUM |
| 78 | + CODE_39_CHECKSUM |
| 79 | + CODE_93 |
| 80 | + EAN_13 |
| 81 | + EAN_2 |
| 82 | + EAN_5 |
| 83 | + EAN_8 |
| 84 | + IMB |
| 85 | + INTERLEAVED_2_5 |
| 86 | + INTERLEAVED_2_5_CHECKSUM |
| 87 | + KIX |
| 88 | + MSI |
| 89 | + MSI_CHECKSUM |
| 90 | + PHARMA_CODE |
| 91 | + PHARMA_CODE_TWO_TRACKS |
| 92 | + PLANET |
| 93 | + POSTNET |
| 94 | + RMS4CC |
| 95 | + STANDARD_2_5 |
| 96 | + STANDARD_2_5_CHECKSUM |
| 97 | + UPC_A |
| 98 | + UPC_E |
| 99 | +
|
| 100 | +Examples: |
| 101 | + barcode -f HTML -e CODE_39 "1234567890" "/tmp/1234567890.html" |
| 102 | + barcode -e CODE_128 -f PNG -c "#888" -w 3 -h 50 "AGREATBAR" "/tmp/AGREATBAR.png" |
| 103 | + barcode "1234567890" "/tmp/mybar.svg" --encoding EAN_13 --format SVG |
| 104 | +``` |
| 105 | + |
| 106 | + |
| 107 | + |
0 commit comments