Skip to content

💸 PHP package to crawl and print out TRA EFD receipts programmatically

License

Notifications You must be signed in to change notification settings

RonnieTaz/tra-crawler

Repository files navigation

Logo

TRA Crawler

A PHP package for crawling TRA receipts and returning its data as a collection, array or json.

Badges

Add badges from somewhere like: shields.io

MIT License

Installation

Install TRA crawler with composer.

  composer require ronnie/tra-crawler

The project also make use of puppeteer to access JS content on the receipt.

  npm install puppeteer

Authors

Usage/Examples

Plain PHP

When using this package in plain PHP, a simple setup like this can help you get started:

  use Ronnie\TRA\Crawler;
  
  ...
  
  $crawler = new Crawler();
  // For URI or QR Scanned receipts you can use the URI method
  $receipt = $crawler->setUri($yourURI)->crawl();

  // For Physical receipt, Receipt verification code and the time is to be used in conjuction with the code method
  $receipt = $crawler->setCode($yourCode, $yourTime)->crawl();

Do note that the time ($yourTime) should be in hhMMss format (124453).

Laravel / Dependency Injection

When using this package in a Laravel/Symfony Project or any project that has a DI container, a better solution would be to use the container to inject an instance of the Ronnie\TRA\Crawler class into whatever class or method you need. A singleton works best for such scenarios.

It is also possible to extend the Ronnie\TRA\Crawler class or write your own implementation as long as they obey the Ronnie\TRA\Contracts\ResourceCrawler contract/interface.

Run Locally

Clone the project

  git clone https://github.com/RonnieTaz/tra-crawler

Go to the project directory

  cd tra-crawler

Install NPM dependencies

  npm install puppeteer

Install Composer dependencies

  composer install

Use CLI app to test output

  php bin/console app:test-output -i url -u the_receipt_url

Also, few sample receipts have been added to the project to simplify testing. Head over to config.php to set which sample you want to use.

About

💸 PHP package to crawl and print out TRA EFD receipts programmatically

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published