DEV Community

Cover image for Introducing Buddy: the PHP sidecar for Manticore Search
Sergey Nikolaev
Sergey Nikolaev

Posted on

Introducing Buddy: the PHP sidecar for Manticore Search

Published: Feb 18, 2023

Manticore Buddy is a PHP-based sidecar and Manticore Search companion that makes development faster and more efficient. In a world where C++ development can be slow, Manticore Buddy empowers developers to swiftly create and deploy features.

Thanks to the PHP language and its massive community, Manticore Buddy provides increased flexibility and user-friendliness. Additionally, with the latest version 8+, PHP is now faster than ever, making it an ideal choice for developers who want to speed up their workflows.

C++ vs. PHP: choosing the right language for your needs

When it comes to building high-performance software, C++ is often the preferred language. However, its development process can be lengthy and complex, leading many developers to seek alternative options that can improve productivity. One such popular language is PHP, which is known for its user-friendly nature and speedy performance.

At Manticore Search, we had a similar issue of needing to release updates frequently while also maintaining high performance. To tackle this, we developed Buddy - a sidecar application that uses PHP to implement features that don’t need maximum performance.

Ultimately, the choice of using C++ or PHP depends on your project’s needs. If top-notch performance is the priority, C++ is the best option. On the other hand, if you prefer faster development and ease of use, PHP may be the smarter choice.

In conclusion, selecting the right language for your project is paramount. It’s important to weigh factors like performance, development time, and ease of use before making a decision. Finding the right balance between these will lead to a successful and efficient project.

Advantages of Using Manticore Buddy

Manticore Buddy is a powerful tool for Manticore Search development, offering several advantages to streamline the development process. Here are some of the key benefits of using Manticore Buddy:

  • Speeding up the development process: the intuitive interfaces of Buddy and PHP make it easy to create efficient features and extensions quickly and with no pain, thus saving time and optimizing workflow.
  • Seamless integration with PHP packages: Manticore Buddy is written in PHP, allowing for easy integration with other PHP-based packages. Developers can use any PHP package, reducing development time and making it a useful and versatile tool. As one of the most popular languages, PHP is a valuable asset for developers.
  • **Improved accessibility for developers of all skill levels: **clear documentation and a user-friendly interface make Buddy accessible to all skill levels. This can result in a broader pool of contributors to the development of Manticore Search, increasing flexibility and offering potential for future improvements.
  • **Shipping extra features without updating C++ codebase: **Buddy enables us to do something powerful: ship improvements, extensions, and even new features without going through our lengthy C++ implementation checklist. Instead, we can do it quickly and reliably with PHP. Manticore Buddy is an invaluable asset for any development team who use Manticore Search and want to extend it themselves. Its intuitive interface, ability to use any PHP packages, and accessibility to developers of all skill levels make it a versatile tool to improve the development process for Manticore Search and offer flexibility to fulfill special requirements.

How Manticore Buddy works

It all sounds great, but you may be wondering how we made Manticore Search and Buddy work together? We’ve implemented an internal protocol for Manticore Search and Buddy to communicate with each other. The process is very simple and straightforward. To add something to Buddy and extend its functionality, you don’t even need to know the protocol, as we have done all the hard work to make it easy to build on top of it.

Let’s take a look at the SHOW QUERIES request as an example:

  • Manticore Search receives a query. If there is no handler for it in the C++ code or the query causes an error, it usually returns that to the user. However, now Manticore Search asks Buddy to try to handle it first.
  • So Manticore Search sends the query to Buddy using an internal communication protocol based on JSON and waits for a reply.
  • Buddy processes the request asynchronously and in parallel using ReactPHP to ensure non-blocking performance. Upon completion, it returns the result to Manticore Search.
  • Finally, the response from Buddy (regardless of whether it is valid or not) is proxied to the client with the results Buddy provided. Done. Easy, right?

The process is so easy and powerful that you can extend and handle custom queries simply by implementing them in PHP in Buddy.

What Manticore Buddy can already do

Manticore Buddy has been developed to support a wide range of functionalities, both big and small, for Manticore Search. The newest version, Manticore 6.0.0, features a selection of these capabilities!

We strove to determine the most critical features to include in the initial version. These include auto-schema, which automatically generates a table based on the first document received, the BACKUP SQL command for easy table backups, and the SHOW QUERIES command to display currently executing queries.

Multi-threading and non-blocking processing are both supported, using the Parallel PHP extension to process queries in separate threads. If Manticore Buddy stops unexpectedly, Manticore Search will detect and automatically restart it.

I want to try! Teach me how to install it?

Installing Manticore Buddy is simple and straightforward. The “manticore-buddy” package is a dependency of the “manticore” package and is automatically installed when you install Manticore Search.

However, for Manticore Buddy to function properly, PHP and a set of modules are required. To simplify this process, we have developed Manticore Executor, a specialized version of PHP that comes pre-compiled with all the necessary modules included.

You just need to install the “manticore” and “manticore-extra” packages to get Manticore Search, Manticore Buddy, and Manticore Executor running. Don’t worry, Manticore Executor is installed in a distinct path, ensuring that it won’t cause any conflicts with your current PHP installations.

What’s next?

Are you excited about the possibilities that Buddy can bring to us? We certainly are! We have some upcoming features that are already complete and ready to ship. Thanks to the user-friendly nature of PHP and Manticore Buddy, we are able to provide these features with ease. Here’s a little spoiler for what’s to come:

  • mysqldump - it’s now easier than ever to dump schema or data with the publicly-used tool for MySQL, making use of mysqldump.
  • MySQL-like table rendering with CLI - Manticore HTTP command-line interface. Yeah, simply send an HTTP request to the /cli endpoint and receive a rendered response that closely resembles the MySQL client interface in the terminal.
  • Pluggable architecture. Imagine being able to create a plugin for Buddy with just a few clicks and a handful of code lines. You could even publish it to the marketplace and browse existing plugins to meet your needs. Sounds incredible, doesn’t it?

You can already test out some of these features by utilizing our Buddy development version. Simply head over to the dev installation section to learn how to install it on your operating system.

Conclusion

Manticore Search is an open source search engine that has been gaining popularity in recent years. It has been designed to handle a wide range of search needs and is used in a variety of applications, from e-commerce websites to online marketplaces. The success of any open source project is largely dependent on the contributions made by developers, and Manticore Search is no exception. And this is the way where Manticore Buddy comes live to help us to ship and move faster for our community.

Manticore Buddy is a powerful and flexible search companion designed to make development of new features and extending functionality of Manticore Search faster and more efficient. Its easy-to-use interface, clear documentation, and massive community make it an ideal choice for any PHP developer looking to speed up their workflows.

As a developer, if you’re looking to unlock the full potential of Manticore Search, you should consider learning and contributing to Buddy. It will make your life easier and allow you to ship things faster without needing to modify C++ code. Just imagine, you can add custom features for your use case simply by writing a PHP plugin. Powerful! 🙂

Top comments (0)