Skip to content

Commit c929529

Browse files
committed
v1.0.6 FixFixFix - Update Readme
1 parent 4ac9d00 commit c929529

2 files changed

Lines changed: 63 additions & 28 deletions

File tree

README.md

Lines changed: 62 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,6 @@ Generates awesome barcodes from CLI using PHP
33
This script uses @picqer's [php-barcode-generator](https://github.com/picqer/php-barcode-generator) to generate barcodes from the command line.
44
For command line parsing @ulrichsg's [getopt-php](https://github.com/ulrichsg/getopt-php) is used.
55

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 run it.
10-
11-
You should download the zip or tar ball and put the cli-barcode folder where you want it to be installed.
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-
266
## Generating barcodes
277
Usage is pretty straight forward.
288
##### There are 4 required parameters
@@ -32,27 +12,58 @@ Usage is pretty straight forward.
3212
4. Output file (where to save it)
3313

3414
##### 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)
15+
* Width factor for the bars, defaults to 2
16+
* Height of the bars, defaults to 30
17+
* Color of the bars, defaults to '#000000' (black)
3818

39-
I find the default settings for these very optimal, since there is usually no problem on resizing the barcodes generated.
19+
I find the default settings for these very optimal, since there is usually no big penalty on resizing the barcodes generated.
4020
The encodings and output formats are case-insenstive.
4121

22+
## Example Runs
23+
#### Blue Colored `CODE_128_C` SVG with "123123123123"
24+
```
25+
$ barcode -v -c '#0030ff' -e CODE_128_C -f SVG "123123123123" $HOME/teste.svg
26+
PHP-CLI Barcode v1.0.6 - Verbose Execution
27+
Output File : /home/guneves/teste.svg
28+
Barcode String : 123123123123
29+
Barcode Encoding : CODE_128_C
30+
Output Format : SVG
31+
Width Factor : 2
32+
Height of Barcode : 30
33+
Hex Color : #0030ff
34+
Final Status : Success
35+
```
36+
#### `CODE_39` PNG with "A GREAT BAR" and custom Width Factor and Height
37+
```
38+
$ barcode -vv -e CODE_39 -f PNG "A GREAT BAR" $HOME/test.png
39+
2017-05-20T06:10:44-03:00 | PHP-CLI Barcode v1.0.6 - Verbose Execution
40+
2017-05-20T06:10:44-03:00 | Output File : /home/guneves/test.png
41+
2017-05-20T06:10:44-03:00 | Barcode String : A GREAT BAR
42+
2017-05-20T06:10:44-03:00 | Barcode Encoding : CODE_39
43+
2017-05-20T06:10:44-03:00 | Output Format : PNG
44+
2017-05-20T06:10:44-03:00 | Width Factor : 2
45+
2017-05-20T06:10:44-03:00 | Height of Barcode : 30
46+
2017-05-20T06:10:44-03:00 | Hex Color : #000000
47+
2017-05-20T06:10:44-03:00 | Final Status : Success
48+
```
4249
## Help Information from cli
4350
```
4451
$ barcode --help
52+
PHP-CLI Barcode v1.0.6
4553
Usage: barcode -e <encoding> -f <output_format> [options] <barcode string> <output file>
4654
Options:
47-
-e, --encoding <bar-type> Barcode encoding type selection
48-
-f, --format <file-type> Output format for the barcode
55+
-e, --encoding <bar-type> Barcode encoding type selection, listed below
56+
-f, --format <file-type> Output format for the barcode, listed below
4957
-w, --width <points> Width factor for bars to make wider, defaults to 2
5058
-h, --height <points> Total height of the barcode, defaults to 30
5159
-c, --color <hex-color> Hex code of the foreground color, defaults to black
52-
-v, --verbose Display extra information
53-
-q, --quiet Supress all messages
60+
Eg. -c 54863b, or -c '#000'
61+
-v, --verbose Prints verbose information to screen
62+
Use twice for timestamp
63+
-q, --quiet Supress all messages, even errors
5464
--help Help Information, including encodings and formats
5565
--version Display version information and exits
66+
--create-bash Creates a shell script named 'barcode' that can call this script
5667
5768
Required Options and Parameters:
5869
-e <encoding>
@@ -105,4 +116,27 @@ Examples:
105116
```
106117

107118

119+
## How to install using `Make`
120+
The vendor folder is included since I want to be able to just download this package and run it.
121+
I have also made some patches upstream on both `getopt-php` and `php-barcode-generator`.
122+
123+
You should download the zip or tar ball and put the cli-barcode folder where you want it to be installed.
124+
Or use git to clone:
125+
```
126+
git clone https://github.com/tavinus/cli-barcode.git $HOME/cli-barcode # <= Replace TARGET
127+
cd $HOME/cli-barcode # <= Replace TARGET
128+
```
129+
130+
Then you can run:
131+
```
132+
./barcode.php --create-bash
133+
```
134+
To recreate the `barcode` file with the full path to your installation.
135+
136+
At this point you can run:
137+
```
138+
sudo make install
139+
```
140+
To copy the shell executable to `/usr/local/bin/barcode`.
141+
108142

barcode.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ function printVersion($suffix='') {
101101

102102
// prints help information
103103
function print_help($getopt) {
104+
printVersion();
104105
global $encodings_list;
105106
global $formats_list;
106107

0 commit comments

Comments
 (0)