DEV Community 👩‍💻👨‍💻

Shobi
Shobi

Posted on

I wrote a PHP Client for sonic, the autosuggestion engine, and now its official PHP client. Ask Me Anything 🤩

Hey guys, last week I got to see one article about a new search engine, similar to elastic search. but built specifically for autosuggestions. Sonic - it is an index based auto-suggestion engine built on Rust lang by the team at crip.chat . a customer engagement platform.

Then I went to their repository (Yep, its open source). And found out that it offers a TCP endpoint rather than an HTTP endpoint/. Meaning in order to use sonic search, you need to connect to the TCP socket and issue commands over the socket and read the output buffer. They are officially offering a javascript client for sonic but not for PHP. Then it struck me... This can be a good experience for me if I build a PHP client for it, especially because I haven't done any socket programming before.

Then I spent a few days and nights cooking the PHP client and submitted a PR into the official repo,

Added one more php client - psonic by ppshobi #118

ppshobi avatar
ppshobi commented on Apr 06, 2019

Hi, I have gone ahead and implemented a PHP client for sonic, including unit tests and a relatively complete readme and an api documentation as well.

Saying that kindly include my client as well in the readme. Then I tweeted about the same in twitter as well.

Ahaa... There it was. The CTO of crisp and the core contributor of Sonic, Mr. Valerian Saliou replied to me saying that, he liked the way I wrote the code and he can promote my client as an officially supported sonic client for PHP if I come up with a relatively complete solution.

Well then..., few more nights and voila. Now Psonic is the official php client for sonic. Check it out, and give your valuable opinions in the comments as well as GitHub stars 😍.

ppshobi / psonic

Sonic is a super fast auto suggestion engine built by the team at crisp.chat, a customer engagement platform. its built in Rust and they officially support a javascript client, but if you want to use sonic via php, this is the library that you can look for. Completely unit tested, and adheres to modern coding standards, and offers a clean api to interact with sonic.

Psonic - PHP client for sonic auto suggestion engine

Build Status Scrutinizer Code Quality codecov

Summary

Sonic is a super fast auto-suggestion engine built by the team at crisp.chat, a customer engagement platform. it is built in Rust and they officially support a javascript client, but if you want to use sonic via PHP, this is the library that you can look for Completely unit tested, and adheres to modern coding standards, and offers a clean API to interact with sonic.

Installation & Usage

you need a running sonic instance (locally or in the cloud, the port 1491 should be accessible) php7+ and composer to make this library work. Read more on installing sonic

  • goto your project directory
  • execute composer require ppshobi/psonic once the installation is completed you should be able to use the library as follows

Api Documentaion

Full API Documentaion

Usage

once you have psonic in place, you have access to the Client

Go ahead and try sonic as well. It's a really cool product. 😍😍😍

Top comments (0)

5 Websites To Learn Frontend Web Development Faster

In this article, Bentil Shadrack has curated 5 resourceful sites that will help you better you web development skills really fast.