- WooCommerce REST API PHP Client Library
“A PHP wrapper for the WooCommerce REST API. Easily interact with the WooCommerce REST API using this library.”
PHP Client: https://github.com/kloon/WooCommerce-REST-API-Client-Library
It still supports the OAuth 1 one-legged (use consumer key and secret for the authentication), limited OOP, no test
Tutorial: https://www.skyverge.com/blog/using-woocommerce-rest-api-introduction/
https://www.skyverge.com/blog/using-woocommerce-rest-api-orders-endpoint/ (complete with curl and Http implementations and samples result)
Great tutorial to use/extend woocommerce: https://www.skyverge.com/blog/category/tutorials/woocommerce-tutorials/.
Category: PHP
PDF TO TEXT CONVERTER
Reference: http://okfnlabs.org/blog/2016/04/19/pdf-tools-extract-text-and-data-from-pdfs.html
I already tested and installed a few good open source code, like pdfparser, pdfbox and pdfminer.
PDFPARSER:
- clone from https://github.com/smalot/pdfparser
- composer install
- test by creating a new file index.php in /works/pdfparser/index.php
12345678910111213141516171819<?phpini_set('display_errors', 1);ini_set('display_startup_errors', 1);error_reporting(E_ALL);// Include Composer autoloader if not already done.//include 'vendor/autoload.php';require_once('vendor/autoload.php');// Parse pdf file and build necessary objects.$parser = new \Smalot\PdfParser\Parser();$pdf = $parser->parseFile('export1.pdf');//$pdf = $parser->parseFile('samples/Document1_foxitreader.pdf');$pages = $pdf->getPages();// Loop over each page to extract text.foreach ($pages as $page) {echo nl2br($page->getText());//echo $page->getText();}?>
NOT GOOD!
PDFBOX:
- clone from https://github.com/schmengler/PdfBox
- composer install
- download jarfile from http://pdfbox.apache.org/index.html (pdfbox-app-2.4.0.jar)
then move it to /usr/bin - test by creating a new file index.php in /works/PdfBox/index.php
1234567891011121314151617<?phpini_set('display_errors', 1);ini_set('display_startup_errors', 1);error_reporting(E_ALL);// Include Composer autoloader if not already done.//include 'vendor/autoload.php';require_once('vendor/autoload.php');//use SGH\PdfBox;//$pdf = GENERATED_PDF;$converter = new \SGH\PdfBox\PdfBox();$converter->setPathToPdfBox('/usr/bin/pdfbox-app-2.4.0.jar');//$text = $converter->textFromPdfStream($pdf);$text = $converter->textFromPdfFile('export1.pdf');echo $text;?>
BUT NEVER WORKS BECAUSE ALWAYS COMPLAIN ABOUT ‘RUNTIME ERROR CANNOT ACCESS JARFILE’. ALREADY SET PERMISSION BUT THE ERROR STILL PERSIST. SO I RUN THE JAR VIA TERMINAL (READ: http://pdfbox.apache.org/2.0/commandline.html)
1java -jar pdfbox-app-2.4.0.jar ExtractText export1.pdf
BUT NOT GOOD!
PDFMINER INSTALLATION:
It use python 2.7
- clone from the source (https://github.com/euske/pdfminer/)
1teddy@teddy-K43SJ:~/Documents/python$ git clone https://github.com/euske/pdfminer.git - Run setup.py
1teddy@teddy-K43SJ:~/Documents/python$ sudo python setup.py install
Here I have to use ‘sudo’ to install because I got permission problem without it - Test
1teddy@teddy-K43SJ:~/Documents/python$ pdf2txt.py -o export1.txt export1.pdf
BEST OF THE OTHERS BUT STILL NOT GOOD! SELECT ALL THE TEXT THEN COPY PASTE STILL BETTER!
I TRIED TO INSTALL TESSERACT BUT EVEN WORSE THEN ABOVE!!!
PHP Tools
Install some PHP tools:
- PHP Coding Standards Fixer (http://cs.sensiolabs.org/)
Installation: (Globally (Composer))
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647teddy@teddy-K43SJ:~$ composer global require friendsofphp/php-cs-fixerChanged current directory to /home/teddy/.composerYou are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebugUsing version ^2.0 for friendsofphp/php-cs-fixer./composer.json has been createdLoading composer repositories with package informationUpdating dependencies (including require-dev)- Installing sebastian/diff (1.4.1)Loading from cache- Installing symfony/stopwatch (v3.2.1)Downloading: 100%- Installing symfony/process (v3.2.1)Downloading: 100%- Installing symfony/polyfill-php54 (v1.3.0)Downloading: 100%- Installing symfony/finder (v3.2.1)Downloading: 100%- Installing symfony/filesystem (v3.2.1)Downloading: 100%- Installing symfony/event-dispatcher (v3.2.1)Downloading: 100%- Installing psr/log (1.0.2)Loading from cache- Installing symfony/debug (v3.2.1)Downloading: 100%- Installing symfony/polyfill-mbstring (v1.3.0)Downloading: 100%- Installing symfony/console (v3.2.1)Downloading: 100%- Installing friendsofphp/php-cs-fixer (v2.0.0)Downloading: 100%symfony/event-dispatcher suggests installing symfony/dependency-injection ()symfony/event-dispatcher suggests installing symfony/http-kernel ()Writing lock fileGenerating autoload files
Then make sure you have ~/.composer/vendor/bin in your PATH and you’re good to go:
1teddy@teddy-K43SJ:~$ export PATH="$PATH:$HOME/.composer/vendor/bin"
To find out the location of php-cs-fixer
12teddy@teddy-K43SJ:~$ which php-cs-fixer/home/teddy/.composer/vendor/bin/php-cs-fixer
I can use the location for the netbeans plugins needed.
Another reference: https://mattstauffer.co/blog/using-php-cs-fixer-to-fix-up-your-php-code - PHP CodeSniffer
Ref: http://purencool.com/install-and-test-phpcodesniffer-on-ubuntu
http://askubuntu.com/questions/572956/adding-a-standard-to-php-codesniffer
Installation:
1234567teddy@teddy-K43SJ:~$ sudo pear install PHP_CodeSniffer[sudo] password for teddy:WARNING: channel "pear.php.net" has updated its protocols, use "pear channel-update pear.php.net" to updatedownloading PHP_CodeSniffer-2.7.1.tgz ...Starting to download PHP_CodeSniffer-2.7.1.tgz (513,716 bytes).....................................................................done: 513,716 bytesinstall ok: channel://pear.php.net/PHP_CodeSniffer-2.7.1
To find out the location
12teddy@teddy-K43SJ:~$ which phpcs/usr/bin/phpcs
To verify PHP_CodeSniffer is already installed, check like this:
12teddy@teddy-K43SJ:~$ phpcs -iThe installed coding standards are PHPCS, Squiz, PSR2, PSR1, PEAR, MySource and Zend
Ref: https://wisdmlabs.com/blog/how-to-format-php-code-to-wordpress-coding-standards-in-netbeans/
To use it in netbeans, click: Source > Inspect… - PHP Mess Detector & PDepend
Ref: https://phpmd.org/download/index.html
http://stackoverflow.com/questions/27958289/what-is-phpmd-and-how-to-use-it
Installation: (Same way with php cs fixer to use composer globally)
12345678910111213141516171819202122232425teddy@teddy-K43SJ:~$ composer global require phpmd/phpmdChanged current directory to /home/teddy/.composerYou are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebugUsing version ^2.5 for phpmd/phpmd./composer.json has been updatedLoading composer repositories with package informationUpdating dependencies (including require-dev)- Installing symfony/dependency-injection (v3.2.1)Downloading: 100%- Installing symfony/config (v3.2.1)Downloading: 100%- Installing pdepend/pdepend (2.3.2)Downloading: 100%- Installing phpmd/phpmd (2.5.0)Downloading: 100%symfony/dependency-injection suggests installing symfony/yaml ()symfony/dependency-injection suggests installing symfony/expression-language (For using expressions in service container configuration)symfony/dependency-injection suggests installing symfony/proxy-manager-bridge (Generate service proxies to lazy load them)symfony/config suggests installing symfony/yaml (To use the yaml reference dumper)Writing lock fileGenerating autoload files
To find out the location for PHPMD and PDepend:
12teddy@teddy-K43SJ:~$ which phpmd/home/teddy/.composer/vendor/bin/phpmd
12teddy@teddy-K43SJ:~$ which pdepend/home/teddy/.composer/vendor/bin/pdepend
12teddy@teddy-K43SJ:~$ which phpunit/usr/local/bin/phpunit
- PHP Copy/Paste Detector (PHPCPD)
Ref: https://github.com/sebastianbergmann/phpcpd
NOTE: DONT INSTALL FROM PEAR!
Installation: (Use composer globally)
1234567891011121314151617181920212223teddy@teddy-K43SJ:~$ composer global require "sebastian/phpcpd=*"Changed current directory to /home/teddy/.composerYou are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug./composer.json has been updatedLoading composer repositories with package informationUpdating dependencies (including require-dev)- Installing theseer/fdomdocument (1.6.1)Downloading: 100%- Installing phpunit/php-timer (1.0.8)Loading from cache- Installing sebastian/version (2.0.1)Downloading: 100%- Installing sebastian/finder-facade (1.2.1)Downloading: 100%- Installing sebastian/phpcpd (2.0.4)Downloading: 100%Writing lock fileGenerating autoload files
To find out the location:
12teddy@teddy-K43SJ:~$ which phpcpd/home/teddy/.composer/vendor/bin/phpcpd
Please read this: Installation of PHP Code Review Tools
For integrating all the above tools in Netbeans!
Update PPA For PHP, Change PHP CLI Version
BEWARE! THIS WOULD MAKE YOUR LOCALHOST NOT WORKING LIKE WEB APP, PHPMYADMIN, ETC. NEED TO BACKUP YOUR DATA FIRST!
I need to update the PPA for php from ppa:ondrej/php5-5.6 to ppa:ondrej/php because the earlier ppa already deprecated. Here is the step for PPA migration to ppa:ondrej php. Continue reading “Update PPA For PHP, Change PHP CLI Version”