Skip to content

Latest commit

 

History

History
139 lines (104 loc) · 3.83 KB

README.md

File metadata and controls

139 lines (104 loc) · 3.83 KB

PHP Barcode Reader for Linux

Version 8.8

The sample demonstrates how to make PHP barcode reader with PHP7 and Dynamsoft Barcode Reader for Linux.

License

Get the trial license.

Installation

  • php-cli, php-dev, and libxml2-dev

    sudo apt install php-cli php-dev libxml2-dev
    
  • Check php version php -v and download the corresponding source code

  • Dynamsoft Barcode Reader SDK

    unzip dbr-c_cpp-8.8.zip
    sudo cp DynamsoftBarcodeReader/Lib/Linux/*.so /usr/lib
    

How to Build the Extension

  1. Unzip PHP source code and then change directory to ext:

    tar xvf php-7.<version>.tar.gz
    cd php-7.<version>/ext/
    
  2. Create an extension folder:

    php ext_skel.php --ext dbr
    cd dbr
    
  3. Copy AllSupportedBarcodeTypes.tif, config.m4, DynamsoftBarcodeReader.h, DynamsoftCommon.h, reader.php and dbr.c to php-7./ext/dbr:

  4. Copy php.ini to /etc/php/7./cli/php.ini.

  5. Build and install the extension:

    phpize
    ./configure
    make
    sudo make install
    
  6. Get a trial license and set it in reader.php:

    DBRInitLicense("LICENSE-KEY");
  7. Run reader.php:

    php -c /etc/php/7.<version>/cli/php.ini reader.php
    

    php barcode reader

Online Barcode Reader with PHP Custom Extension

Get the source code and deploy it to any web server.

php online barcode reader

PHP on Apache

  1. Install php7.-curl, apache2 and libapache2-mod-php7.:

    sudo apt-get install php7.<version>-curl apache2 libapache2-mod-php7.<version>
    
  2. Add extension to /etc/php/7.<version>/apache2/php.ini :

    extension=dbr.so
    
  3. Get write permissions:

    sudo chgrp -R www-data /var/www/html/reader
    sudo chmod -R g+rw /var/www/html/reader
    
  4. Start Apache:

    sudo service apache2 start
    #sudo service apache2 stop // if you want to stop Apache
    
  5. Visit http://localhost/reader/index.php.

PHP on Nginx

  1. Install Nginx and php7.-cgi:

    sudo apt-get install nginx php7.<version>-cgi
    
  2. Enable PHP in configuration file:

    sudo vi /etc/nginx/sites-available/default
    
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    
    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
    
            # With php7.<version>-cgi alone:
            fastcgi_pass 127.0.0.1:9000;
            # With php7.<version>-fpm:
            #fastcgi_pass unix:/run/php/php7.<version>-fpm.sock;
    }
    
  3. Get write permissions:

    sudo chgrp -R www-data /usr/share/nginx/html/reader
    sudo chmod -R g+rw /usr/share/nginx/html/reader
    
  4. Run Nginx and php-cgi:

    sudo nginx
    # sudo nginx –s stop // if you want to stop Nginx
    sudo php-cgi -b 127.0.0.1:9000 -c /etc/php/7.<version>/cli/php.ini
    
  5. Visit http://localhost/reader/index.php.

Blog