Commit 6b62e0c1 by 肖康
parents 93fda0b3 29e32f47
<?php
/**
* Created by PhpStorm.
* User: ICHUNT
* Date: 2020/5/9
* Time: 16:02
*/
return [
'store_path' => public_path(),
];
\ No newline at end of file
/vendor
composer.phar
composer.lock
.DS_Store
.idea
\ No newline at end of file
language: php
php:
- 5.3
- 5.4
- 5.5
before_script:
- curl -s http://getcomposer.org/installer | php
- php composer.phar install --dev
script: phpunit
\ No newline at end of file
{
"name": "milon/barcode",
"description": "Barcode generator like Qr Code , PDF417,C39, C39+,C39E,C39E+,C93,S25,S25+,I25,I25+,C128,C128A,C128B,C128C,2-Digits UPC-Based Extention,5-Digits UPC-Based Extention,EAN 8,EAN 13,UPC-A,UPC-E,MSI (Variation of Plessey code) ",
"keywords": ["barcode", "laravel","qrcode","QR Code","PDF417","Datamatrix","CODE 39","CODE 128","EAN","CODABAR"],
"license": "LGPL-3.0",
"authors": [
{
"name": "Nuruzzaman Milon",
"email": "contact@milon.im"
}
],
"require": {
"php": ">=5.4.0",
"illuminate/support": "5.*"
},
"autoload": {
"psr-0": {
"Milon\\Barcode": "src/"
}
},
"minimum-stability": "stable"
}
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
\ No newline at end of file
This is a barcode generation package inspired by [https://github.com/tecnickcom/TCPDF](https://github.com/tecnickcom/TCPDF). Actually I use that package's underline classes for generating barcode. This package is just a wrapper of that package and adds compatibility with Laravel 5.
I used the following classes of that package.
- src/Milon/Barcode/Datamatrix.php (include/barcodes/datamatrix.php)
- src/Milon/Barcode/DNS1D.php (tcpdf_barcodes_1d.php)
- src/Milon/Barcode/DNS2D.php (tcpdf_barcodes_2d.php)
- src/Milon/Barcode/PDF417.php (include/barcodes/pdf417.php)
- src/Milon/Barcode/QRcode.php (include/barcodes/qrcode.php)
[Read More on TCPDF website](http://www.tcpdf.org)
### This package is compatible with Laravel 5.2
## Installation
Begin by installing this package through Composer. Just run following command to terminal-
```
composer require milon/barcode
```
You can also edit your project's `composer.json` file to require `milon/barcode`.
"require": {
...
"milon/barcode": "^5.2"
}
For Laravel 5.0 and 5.1 use this-
"require": {
...
"milon/barcode": "^5.1"
}
For Laravel 4.0, 4.1 and 4.2 use this-
"require": {
...
"milon/barcode": "^4.2"
}
Next, update Composer from the Terminal:
composer update
Once this operation completes, the final step is to add the service provider. Open `config/app.php`, and add a new item to the providers array.
```php
'providers' => [
...
Milon\Barcode\BarcodeServiceProvider::class,
...
]
```
For version 4.* add these lines on `app/config/app.php` file-
```php
'providers' => array(
...
'Milon\Barcode\BarcodeServiceProvider',
)
```
If you want to change Bar-code's settings (Store Path etc.), you need to publish its config file(s). For that you need to run in the terminal-
php artisan vendor:publish
Make sure you have write permission to the storage path. By default it sets to `/storage` folder.
Now add the alias.
```php
'aliases' => [
...
'DNS1D' => Milon\Barcode\Facades\DNS1DFacade::class,
'DNS2D' => Milon\Barcode\Facades\DNS2DFacade::class,
]
```
For version 4.2 alias will be like this-
```php
'aliases' => array(
...
'DNS1D' => 'Milon\Barcode\Facades\DNS1DFacade',
'DNS2D' => 'Milon\Barcode\Facades\DNS2DFacade',
)
```
Bar-code generator like
Qr Code,
PDF417,
C39,C39+,
C39E,C39E+,
C93,
S25,S25+,
I25,I25+,
C128,C128A,C128B,C128C,
2-Digits UPC-Based Extention,
5-Digits UPC-Based Extention,
EAN 8,EAN 13,
UPC-A,UPC-E,
MSI (Variation of Plessey code)
generator in html, png embedded base64 code and SVG canvas
```php
echo DNS1D::getBarcodeSVG("4445645656", "PHARMA2T");
echo DNS1D::getBarcodeHTML("4445645656", "PHARMA2T");
echo '<img src="data:image/png,' . DNS1D::getBarcodePNG("4", "C39+") . '" alt="barcode" />';
echo DNS1D::getBarcodePNGPath("4445645656", "PHARMA2T");
echo '<img src="data:image/png;base64,' . DNS1D::getBarcodePNG("4", "C39+") . '" alt="barcode" />';
```
```php
echo DNS1D::getBarcodeSVG("4445645656", "C39");
echo DNS2D::getBarcodeHTML("4445645656", "QRCODE");
echo DNS2D::getBarcodePNGPath("4445645656", "PDF417");
echo DNS2D::getBarcodeSVG("4445645656", "DATAMATRIX");
echo '<img src="data:image/png;base64,' . DNS2D::getBarcodePNG("4", "PDF417") . '" alt="barcode" />';
```
## Width and Height example
```php
echo DNS1D::getBarcodeSVG("4445645656", "PHARMA2T",3,33);
echo DNS1D::getBarcodeHTML("4445645656", "PHARMA2T",3,33);
echo '<img src="' . DNS1D::getBarcodePNG("4", "C39+",3,33) . '" alt="barcode" />';
echo DNS1D::getBarcodePNGPath("4445645656", "PHARMA2T",3,33);
echo '<img src="data:image/png;base64,' . DNS1D::getBarcodePNG("4", "C39+",3,33) . '" alt="barcode" />';
```
## Color
```php
echo DNS1D::getBarcodeSVG("4445645656", "PHARMA2T",3,33,"green");
echo DNS1D::getBarcodeHTML("4445645656", "PHARMA2T",3,33,"green");
echo '<img src="' . DNS1D::getBarcodePNG("4", "C39+",3,33,array(1,1,1)) . '" alt="barcode" />';
echo DNS1D::getBarcodePNGPath("4445645656", "PHARMA2T",3,33,array(255,255,0));
echo '<img src="data:image/png;base64,' . DNS1D::getBarcodePNG("4", "C39+",3,33,array(1,1,1)) . '" alt="barcode" />';
```
## 2D Barcodes
```php
echo DNS2D::getBarcodeHTML("4445645656", "QRCODE");
echo DNS2D::getBarcodePNGPath("4445645656", "PDF417");
echo DNS2D::getBarcodeSVG("4445645656", "DATAMATRIX");
```
## 1D Barcodes
```php
echo DNS1D::getBarcodeHTML("4445645656", "C39");
echo DNS1D::getBarcodeHTML("4445645656", "C39+");
echo DNS1D::getBarcodeHTML("4445645656", "C39E");
echo DNS1D::getBarcodeHTML("4445645656", "C39E+");
echo DNS1D::getBarcodeHTML("4445645656", "C93");
echo DNS1D::getBarcodeHTML("4445645656", "S25");
echo DNS1D::getBarcodeHTML("4445645656", "S25+");
echo DNS1D::getBarcodeHTML("4445645656", "I25");
echo DNS1D::getBarcodeHTML("4445645656", "I25+");
echo DNS1D::getBarcodeHTML("4445645656", "C128");
echo DNS1D::getBarcodeHTML("4445645656", "C128A");
echo DNS1D::getBarcodeHTML("4445645656", "C128B");
echo DNS1D::getBarcodeHTML("4445645656", "C128C");
echo DNS1D::getBarcodeHTML("44455656", "EAN2");
echo DNS1D::getBarcodeHTML("4445656", "EAN5");
echo DNS1D::getBarcodeHTML("4445", "EAN8");
echo DNS1D::getBarcodeHTML("4445", "EAN13");
echo DNS1D::getBarcodeHTML("4445645656", "UPCA");
echo DNS1D::getBarcodeHTML("4445645656", "UPCE");
echo DNS1D::getBarcodeHTML("4445645656", "MSI");
echo DNS1D::getBarcodeHTML("4445645656", "MSI+");
echo DNS1D::getBarcodeHTML("4445645656", "POSTNET");
echo DNS1D::getBarcodeHTML("4445645656", "PLANET");
echo DNS1D::getBarcodeHTML("4445645656", "RMS4CC");
echo DNS1D::getBarcodeHTML("4445645656", "KIX");
echo DNS1D::getBarcodeHTML("4445645656", "IMB");
echo DNS1D::getBarcodeHTML("4445645656", "CODABAR");
echo DNS1D::getBarcodeHTML("4445645656", "CODE11");
echo DNS1D::getBarcodeHTML("4445645656", "PHARMA");
echo DNS1D::getBarcodeHTML("4445645656", "PHARMA2T");
```
## License
This package is published under `GNU LGPLv3` license and copyright to [Nuruzzaman Milon](http://milon.im). Original Barcode generation classes were written by Nicola Asuni. The license agreement is on project's root.
License: GNU LGPLv3
Package Author: [Nuruzzaman Milon](http://milon.im)
Original Barcode Class Author: [Nicola Asuni](http://www.tcpdf.org)
Package Copyright: Nuruzzaman Milon
Barcode Generation Class Copyright:
Nicola Asuni
Tecnick.com LTD
www.tecnick.com
<?php
namespace Milon\Barcode;
use Illuminate\Support\ServiceProvider;
class BarcodeServiceProvider extends ServiceProvider {
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;
/**
* Publish asset
*/
public function boot() {
$this->publishes([
__DIR__.'/../../config/config.php' => config_path('barcode.php'),
]);
}
/**
* Register the service provider.
*
* @return void
*/
public function register() {
$this->app->bind('DNS1D', function() {
return new DNS1D;
});
$this->app->bind('DNS2D', function() {
return new DNS2D;
});
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides() {
return array("DNS1D", "DNS2D");
}
}
<?php namespace Milon\Barcode\Facades;
use Illuminate\Support\Facades\Facade;
class DNS1DFacade extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor() {
return 'DNS1D';
}
}
<?php namespace Milon\Barcode\Facades;
use Illuminate\Support\Facades\Facade;
class DNS2DFacade extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor() {
return 'DNS2D';
}
}
<?php
return [
'store_path' => public_path("/"),
];
<?php
/*
|--------------------------------------------------------------------------
| Milon/Barcode Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::get('/barcodes', function() {
return "barcodes";
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment