Class 'Google\Protobuf\Internal\Message' not found in "Message.proto"

Viewed 3436

I'm working on a project with protocol buffers and after i compiled a proto file, i cant seem to include it neither run it cos it keeps giving me this exact error: PHP Fatal error: Class 'Google\Protobuf\Internal\Message' not found in /app/generated_files/message.php on line 13

On message.php i have the auto generated file from a .proto file and it includes Google\Protobuf\Internal\Message.

While reading on the protobuf github issues, i found that a person had the same problem where he concluded that it was the composer's fault. However in my case that wouldnt be the issue cos i didnt use composer.

I used pecl to install protocol buffers, and i have the library protobuf.so located in /etc/php5/apache2/XXXXXXXXX. I also added extension=protobuf.so on the last line of php.ini.

Keep in mind that im using docker for everything, therefore it might be something different but i still doubt.

2 Answers

In case anyone ends up here with the same question: you just need to add componser autoloader to your file include_once './vendor/autoload.php'; (change path as required)

I had the same problem, but the reason was different for me: Git somehow messed up the casing of the folders, which lead to a wrong file path translation. As soon as I fixed the casing ([...]/src/Google/Protobuf instead of [...]/src/google/protobuf in the vendor folder)

Related