meilisearch-php: Meilisearch giving error 405 http status

Hi dears , meilisearch giving such error when search (request type post)

Fatal error: Uncaught Meilisearch InvalidResponseBodyException: Http Status: 405 thrown in /var/www/html/vendor/meilisearch/meilisearch-php/src/Http/Client.php on line 186

This error dont giving in meilisearch itself servise (related 127.0.0.1:7700)

VPS info:

4 cores | RAM 8 GB | 100 GB (100% NVMe) | 200 Mbit/s

Also i connect meilisearch from php with docker

Docker conf is:

meilisearch:
          image: 'getmeili/meilisearch:latest'
          ports:
          - '7700:7700'
          volumes:
          - './Docker/meilisearch/volume/:/meili_data'
          networks:
            customnetwork:
              ipv4_address: 172.20.0.13
          healthcheck:
              test: ["CMD", "wget", "--no-verbose", "--spider",  "5"]
              retries: 3
              timeout: 5s

Connection define is :

<?php

MEILISEARCH_CONNECT = 'http://172.20.0.13:7700';

const MEILISEARCH_MASTER_KEY = 'masterKey';

const MEILISEARCH_INDEX_KEY = 'products';
  • OS: [Ubuntu 22]
  • Meilisearch version: [v.0.28.1]
  • meilisearch-php version: [packagist v0.24.0]

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 27 (9 by maintainers)

Most upvoted comments

If you want to use a plain curl is up to you, but the idea of our SDKs is to help you integrate with Meili easily 😃

So, I spotted some trouble in your environment.

First, you must use a version of the Meilisearch engine that is compatible with meilisearch-php. So if you have the engine version 0.27, you should stay on the version of meilisearch-php you have.

But I assume you are using the new version of Meili, so you should run composer update meilisearch/meilisearch-php to get the meilisearch-php v0.24.0, this should solve your problem.

Btw: Our docs only show the latest version of the Meilisearch engine, that’s why you got these issues 😄.

  1. It is annoying that the “latest” of two of your packages don’t work together. The latest Docker image doesn’t work with the latest PHP package. For this issue, I think you should update your Docker image to run the 0.28 version of Meilisearch.

I understand your frustration, but you need to know that latest tag behavior is not something we can control, because it entirely depends on the users’ environment (unfortunately).

I also suggested the docs team change that instruction from the main docs website https://docs.meilisearch.com/learn/getting_started/quick_start.html#setup-and-installation if you check it out, you’ll see a specific tag currently v0.28.0 instead of latest to prevent that from happening.

  1. It is problematic that the PHP package doesn’t do any type of version checking against the server. The server API was changed in MS 0.28.0 , the PHP package v0.24.0 was updated too (good) but should refuse to connect to anything lower than MS 0.28.0, as doing so will reseult in a mysterious crash (the one reported here). A version check would have prevented that.

That’s a pretty good idea, and this could also be applied to other SDKs (we received this kind of feedback before). Unfortunately, due to some time restrictions, we did not have enough time to create a solid plan to implement it yet.

Thanks for using Meilisearch 🤘

Hi @brunoocasali I have same trouble:

Error notice: MeiliSearch\Exceptions\InvalidResponseBodyException

In

MeiliSearch\Http\Client::parseResponse
vendor/meilisearch/meilisearch-php/src/Http/Client.php:186

Laravel version: 8.* Package version: “0.28.1” “meilisearch/meilisearch-php”: “^0.24.1”,

My code version one:

$index = $client->index('movies_index_new');
$index->updateSortableAttributes(['cinemas.name']);

My code version two:

        $index = $client->index('movies_index_new');
        $index->updateSettings([
            'sortableAttributes' => [
                'cinemas.name'
            ]
        ]);

I need custom sorting and filtering. But in both code versions I have the error MeiliSearch\Exceptions\InvalidResponseBodyException

But if I use simple code it’s worked fine:

return Movie::search($q)->get();

If you want to use a plain curl is up to you, but the idea of our SDKs is to help you integrate with Meili easily 😃

So, I spotted some trouble in your environment.

First, you must use a version of the Meilisearch engine that is compatible with meilisearch-php. So if you have the engine version 0.27, you should stay on the version of meilisearch-php you have.

But I assume you are using the new version of Meili, so you should run composer update meilisearch/meilisearch-php to get the meilisearch-php v0.24.0, this should solve your problem.

Btw: Our docs only show the latest version of the Meilisearch engine, that’s why you got these issues smile.

I will check in next project 😃 Thanks for helping again ! 😃