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

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.

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

"Cannot declare class X because the name is already in use" after change in length in Symfony, Doctrine

Been scratching my head over this for hours.
I've inherited a large PHP project and it's now my responsibility.
I also admit that I am not very experienced with Symfony.
Looked all over StackOverFlow for help, but still cannot resolve the following issue.
I made a change in \src\Entity\SOMETHING\BLAH.PHP
Now when I run php bin/console make:migration I get the following error:
[Symfony\Component\Debug\Exception\FatalErrorException]
Compile Error: Cannot declare class App\Entity\SOMETHING\BLAH, because the name is already in use
All I changed was the string length of a column.
#ORM\Column(type="string", length=100, nullable=true)
I've tried moving the migration file that defined the table orignally out of the src folder
I've tried clearing the vendor and node_modules folders, and running
npm and composer install.
I've tried cache:clear command
I've searched the code, and the class is only defined once. Any help greatly appreciated.
The issue was that there were two files in the same directory with the same name, however with a different case (BLAH.php and Blah.php). For reasons unknown, the "duplicate" files did not show in any source code editor, nor in any ls commands to the directory, nor in any text searches with grep.
After moving one of the conflicting files, it was noticed when doing an ls that the other file with a different case was there. It was not visible prior to moving the file. After removing the other file and moving the original back, then the code compiled.
In summary: a possible file-system glitch was preventing files with the same name but a different case from being visible.

The google-api-php-client autoupload.php file is missing, anyone have a copy?

Here's the code, https://github.com/google/google-api-php-client/
Here's the file that's missing, https://github.com/google/google-api-php-client/blob/master/src/Google/autoload.php
I know it's possible to create this file with composer, but was just wondering if anyone has it available.
I'm also concerned that this alone might not make the software work, as I've tried to do it the manual way and the Class it can't reference is "GuzzleHttp\Collection" which is accessed in PHP with "use GuzzleHttp\Collection". I don't know how adding "autoload.php" will help referencing a file that's not part of the "google-api-php-client".
Does anyone actually have this software working in PHP, it says Beta?
I found it using Google Cache,
http://webcache.googleusercontent.com/search?q=cache:992oyuQ76a0J:https://github.com/google/google-api-php-client/blob/master/src/Google/autoload.php+&cd=1&hl=en&ct=clnk&gl=us
This file should be load from vendor directory
// include your composer dependencies
require_once 'vendor/autoload.php';

aws-php-sdk -- Installing without a package manager

I'm working on pulling in the AWS PHP SDK and am running into some issues since my current stack isn't using a package manager. It's not an option to start using it, either (company related -- would rather not elaborate).
That all being said, I'm pulling in the source directly and trying to add it to my include path and just including the files as I need them in my S3 wrapper objects that I'm writing. However, it's running into issues with the namespaces (I think) and those blowing up.
This is the library I'm referring to:
https://github.com/aws/aws-sdk-php
I tried following the bit at the bottom about working with AmazonS3 and uploading a file to it. So, I attempted to include the various parts of the code it referenced as follows:
Attempt One
require_once('/includes/third_party/aws-sdk-php-master/src/Aws/Common/Aws.php');
require_once('/includes/third_party/aws-sdk-php-master/src/Aws/S3/Enum/CannedAcl.php');
require_once('/includes/third_party/aws-sdk-php-master/src/Aws/S3/Exception/S3Exception.php');
Attempt Two
set_include_path(get_include_path() . "/includes/third_party/aws-sdk-php-master/src/");
include('Aws/Common/Aws.php');
include('Aws/S3/Enum/CannedAcl')
include('Aws/S3/Exception/S3Exception.php');
Both of these produced a similar error:
Fatal error: Class 'Guzzle\Service\Builder\ServiceBuilderLoader' not found in \includes\third_party\aws-sdk-php-master\src\Aws\Common\Aws.php on line 26
PHP Fatal error: Class 'Guzzle\Service\Builder\ServiceBuilderLoader' not found in \includes\third_party\aws-sdk-php-master\src\Aws\Common\Aws.php on line 26
Any advice on how to start debugging this? Would be much appreciated!
The AWS SDK for PHP nows ships a zip file with everything you need, including an autoloader: http://docs.aws.amazon.com/aws-sdk-php-2/guide/latest/installation.html#installing-via-zip.
You should stick the the recommend installation procedures. Personally, I would go with the Composer installation or just use the PHAR without Composer.
Then you just need to include the PHAR like:
require '/path/to/aws.phar';
And you will have everything you need.
The problem you have now is likely that you are not taking advantage of the autoloader. Using your approach, you will need to manually include all the classes that would normally be autoloaded.
You also need to download and include another library (Guzzle, not included in the PHAR archive).

Doctrine inextricable string of require_once dependancies

I am trying to use a pear installation of Doctrine, it seems like all of the Requires and Class Names are just looking in the wrong places... do I need to be updating this all in cli-config.php (or similar file)? I don't understand how to get all of these things resolved.
before I go hard-coding all of the requires, I assume there is an elegant way to get this to work. for instance...
Class 'Doctrine\DBAL\Configuration' not found in
/usr/local/pear/share/pear/Doctrine/ORM/Configuration.php on line 41
so my pear install path is /usr/local/pear and the pear doctrine install seems to be /usr/local/pear/share/pear/Doctrine
I have been reading documents, and it seems to work in the sandbox from the cli, but, I don't really have a very modern understanding of PHP. I have been looking through the documentation, and there is probably a very simple step that I am missing, but I do not see it.
try running php like
php -d include_path=/usr/local/pear/share/pear
if this works, you may be missing that path in your include_path
try to issue a phpinfo() or var_dump(ini_get('include_path')) to actually see your include path, the directory Doctrine should be located somewhere inside that path

Error with propel-generate-crud in Symfony 1.0

When I try to generate a CRUD test for a new project I am getting a PHP Warning and a Fatal Error.
The errors relate to files that it cannot find, however, I have checked and the files are definitely there.
The error text is 'require_once(lib/model/map/QuestionMapBuilder.php): failed to open stream: No such file or directory in c:\webroot\askeet\lib\model\om\BaseQuestionPeer.php on line 547'
What details of my project should I check?
I think it's a problem with your include path.
Check it, the require_once() call is looking for lib/model/map/QuestionMapBuilder.php
But your include_path is C:\webroot\askeet\lib
Which, when resolved together into a full path, would look like this
C:\webroot\askeet\lib\lib\model\map\QuestionMapBuilder.php
So, I think your solution is to add C:\webroot\askeet to your include path.
You are generating crud for the Question model class but it doesn't seem to exist. Documentation on using the crud generator
First you must use the schema.yml file to define your database, and run
./symfony propel:build-model
to generate your model files. (this will generate lib\model\map\QuestionMapBuilder.php)
I finally tracked down the issue. In my PHP.ini files, they were setup wit the default UNIX file path settings.
Weirdly nothing had ever been broken by this incorrect configuration. Plus, everything in Symfony had worked up until now.
I have switched to Windows style file_path and all is well again.
Thanks for all the answers!

Categories