PHP SDK: OCR Invoices & Receipts in Seconds

November 29, 2021
5 mins read
PHP SDK: OCR Invoices & Receipts in Seconds

    I love these blog posts. Writing allows me to express my love for chess and technology in a splendid unity. My wife thinks I can be boring when I rave about chess history. I love chess and the history of chess. I hope this short introduction will resonate with you as it does to me between chess and technology.

    Circa 1921, José Raul Capablanca won the world chess championship against Emanuel Lasker. People were surprised about the excellent performance of Capablanca. They said “he played like a Machine! no emotions, no feelings, and most of all, zero mistakes.”

    Exactly! Machines don’t make mistakes…

    During a chess game, players will cycle through many emotions like tension, nervousness, and anxiety which can impact the chess player’s ability to make winning decisions.

    Fast forward to 2021… technology is at the core of most things we do.

    Every company in the world engages in some form of data extraction. Some do it for accounts payable automation, others for optimizing costs, and a handful of contrarian startups for business intelligence to build new business models that automate and free humans to do more. What you might not know, is that most are done by humans or unscalable technologies like templates. The challenge is to move to a full AI solution that’s trained on hundreds of millions of documents to do this job faster, smarter, and with less error than those arcadic approaches.

    Gary Kasparov, one of the biggest chess player in the History of chess, was the first world champion to be defeated by a machine. Instead of continuing a futile fight, he recognized that the machines are superior. Gary, a well-known speaker in the tech community, educates about the importance of machines freeing humanity from tedious tasks to succeed together in achieving humanity’s goals.

    Hello Veryfi

    So, how do we achieve superior data extraction using machines in real time? Veryfi. Veryfi empowers organizations to transform their unstructured data in the form of receipts, invoices, purchase orders, checks, W2s, and other business documents into structured data at scale. Veryfi’s suite of data transformation APIs can be leveraged for many use cases in financial services to deliver valuable business intelligence in seconds.

    Veryfi Project

    Veryfi continues to learn and improve, another key reason our software is so successful. Let’s delve into the details on how to integrate Veryfi with this short project. Veryfi also provides similar projects in other languages like Node.js, Python, Go, and so on. For now, though, we’ll run this show move-by-move like a chess game.

    Before We Begin

    For a better understanding of how this SDK operates, check out the Github README

    Here, you can check out a basic use case before we begin. However, if you already have a coding background, you can always look at the API documentation for the full list of functions.

    By the way, this is an open-source project, so feel free to contribute! Just make a pull request, and our team will be ready to review it 😉

    Move One

    In the root of your project, run the command line

    composer require veryfi/veryfi-php

    And include this in your PHP file

    // First, include the autoload file generated by Composer
    require_once "path_to_your_vendor_autoload";
    
    // Then use the Veryfi API
    use veryfi\Client;

    Move Two

    To use Veryfi, you will need your credentials. Visit our signup page to register or begin a free trial. After you log in, go to settings, and copy the following credentials:  clientId, clientSecret, username, apiKey.

    Once you have them, add this line in your code to create the Veryfi client on PHP.

    $veryfi_client = new Client($client_id, $client_secret, $username, $api_key)

    Move Three

    Go to the part of your project you want to call Veryfi to process a document and just call the line below:

    $json_response = json_decode($veryfi_client->process_document($file, $categories, $delete_after_processing), $return_associative);

    After that, you will have the JSON data from  $file  ready for you to use.

    That’s what I call checkmate in three! My favorite puzzles.

    Veryfi SDKs allows you to customize your request with the ability to specify extra parameters, there are more options and functions that depend on the needs of your application, so you will free to use what you want or create new functions as this an open-source project,  you can check the full list in the API docs in your Veryfi Hub.

    In the initial history of chess Gary Kasparov was skeptical about use machines, once he accepted they are superior he started using them to improve his game and his knowledge and understanding of chess, These days most of the chess players use machines to improve their game, and it is really hard to improve without the help of the machines, the life is a constant evolution to become better than before and Veryfi is part of this evolution, providing faster and easier solutions to solve the problems of data extraction in real time. Veryfi provides value to companies and developers to improve many areas saving money and time, and only with 3 moves, you will be ahead of your competitors. That’s why Veryfi is the rocket ship that you need to take to go to the future in the proper way to automate data extraction and do real-time processing of financial documents.

    — Alejandro
    Head of Mobile Engineering at Veryfi

    Feedback

    GitHub issues: if you want to leave public feedback, please open a GitHub issue in the Veryfi PHP SDK Github Repository. Doing so may also help any other users experiencing the same problem and grow the conversation. We make sure to evaluate issues on our end too, so we can address them in future releases.

    Contact us: If you want to speak with our team privately to ask questions, give feedback, or make a feature request, please email us at support@veryfi.com.

    Contributing

    You can always make pull requests for new fixes or features to the Veryfi PHP SDK. Please ensure your requests are made under the MIT license. Our team also reviews any requests before they’re merged, so unit tests are gladly accepted.