Skip to main content
Build a REST app that performs OpenSearch operations through an OpenSearchDemoController. You use Winter Boot for the application runtime and the Winter OpenSearch module from Winter Modules for search and analytics.

Prerequisites

You need PHP 8.5 or later with the swoole and pcntl extensions. You also need access to an OpenSearch cluster. The sample config points at https://localhost:9200 with basic auth — replace the host and credentials with your own cluster.

Project structure

The sample uses this layout:

Install dependencies

Require the framework and the modules package:

Source files

Switch between the source files. Each tab shows the exact file from the sample.
The single entry point. It points Winter Boot at the config directory and at the sample namespace.

Configuration

Switch between the two config files. application.yml enables the module, and opensearch-config.yml defines the primary connection with basic auth.
The full sample file registers OpenSearchModule and sets the server and app identity:
See Configuration for every application.yml key.

Run the app

Start the app, then call the endpoints to check connectivity, index a document, and search it back. 1. Start the application:
2. Check cluster connectivity:
3. Create an index:
4. Index a document:
5. Get the document:
6. Search documents:
7. Run the complete demo:
The demo creates its own index, runs create, index, bulk, get, update, search, count, and delete in sequence, and returns one status entry per operation.

Next steps

  • Read the OpenSearch module for the full OpenSearchTemplate API and AWS SigV4 signing.
  • Browse all Libraries when you need Kafka, SQS, Redis, or Doctrine in the same app.