Class MongoDB\Driver\Query' not found, MongoDB installed - php

For this installation:
Nginx 1.11.10
Yii Framework 2.0.12 ("yiisoft/yii2-mongodb": "^2.0")
PHP MongoDB library (mongodb 1.2.9, compatible with PHP Version: PHP 5.4.0 or newer)
PHP 5.4.16
Plesk Onyx 17.0.17
No IPTables rules
Strangely enough they function when you visit the website the first time. I can also see data pulled from the Mongo database. But when visiting another page within 10-20 seconds, this error will appear:
25403#0: *170 FastCGI sent in stderr: "PHP message: PHP Fatal error: Class 'MongoDB\Driver\Query' not found in /var/www/vhosts/website.com/website.com/vendor/yiisoft/yii2-mongodb/Command.php on line 284" while reading response header from upstream
PHP Fatal Error – yii\base\ErrorException
Class 'MongoDB\Driver\Query' not found
1. in /var/www/vhosts/website.com/website.com/vendor/yiisoft/yii2-mongodb/Command.php at line 284
try {
$this->beginProfile($token, __METHOD__);
$query = new \MongoDB\Driver\Query($this->document, $options);
However, if you wait another 10-20 seconds, the website works just fine.

I solved it in a yii2 docker alpine nginx image, doing this:
FROM local/dmstr/php-yii2:latest-alpine-nginx
RUN apk --update add autoconf g++ make && \
pecl install mongodb
RUN echo "extension=mongodb.so" > /usr/local/etc/php/conf.d/docker-php-ext-mongodb.ini
You must install mongodb and then create an ini file for the extension on your system's php extensions directory, like I did. Remember to put extension=mongodb.so on it.

Related

Docker container fails to build when installing GRPC

I have a Dockerfile that when used with my docker-compose commands works fine, I'd like to have this docker container built however as GRPC takes 15 mins to install every time I want to run tests in GitHub Actions
This is what my Dockerfile currently looks like:
FROM xxx-base:6
RUN pecl install grpc \
&& docker-php-ext-enable grpc \
WORKDIR /application
And I get the following error output:
#5 580.4 g++: fatal error: Killed signal terminated program cc1plus
#5 580.4 compilation terminated.
#5 580.4 make: *** [Makefile:248: src/core/ext/filters/client_channel/lb_policy/xds/cds.lo] Error 1
#5 580.5 ERROR: `make' failed
------
executor failed running [/bin/sh -c sudo pecl install grpc && docker-php-ext-enable grpc WORKDIR /application]: exit code: 1
It's worth mentioning in the base container used here I used pecl to install imagik so I know that command at least partially works. This is a base PHP 7.4 container.
Any suggestions, I've seen some other posts referring to the memory limit on the docker build, but I'm not sure what to change
Pastebin full stacktrace: pastebin.com/g7iZ2uRn
Installing GRPC in a pipeline takes a long time.
I recommend using the cache of the provider used (bitbucket, github etc ..) or using a base image which is used as the starting point of the Dockerfile
FROM baseimage:latest
I have implemented an image based on alpine and php 7.4 with extension grpc installed, check it on github gits click here
In case gcc –version says anything less than 4.9 ...this might be the cause.
This answer also seems to be related to your scenario... in case PECL fails.

Django - can't do migrations, MySQL 5.7.19, Py 3.6.2 [duplicate]

This question already has answers here:
mysql_config not found when installing mysqldb python interface
(36 answers)
Closed 5 years ago.
Help I'm stuck in Django hell!
I'm trying to learn Django and I'm trying to set up a test site on my own computer (MacOS 10.12.6). My version of Python is 3.6.2 with Django 1.11.4 and MySQL 5.7.19.
I am at the point where I want to do:
python manage.py migrate
BUT... it doesn't work... I have installed mysql-connector 2.1.6 and that particular version seems to have a bug which is documented here. The error posted looks like mine. MySQL said the bug was fixed in version 2.1.7, but I can't download that with pip and I don't see it anywhere. The only other version higher that pip sees is 2.2.3 and that doesn't install at all.
I found other instructions that suggested using mysqlclient (and here), but even that doesn't work. I get this error...
pip install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-1.3.10.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/d9/z3yxpfl505s_jwtty_x3576h0000gn/T/pip-build-8vj20eqa/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/private/var/folders/d9/z3yxpfl505s_jwtty_x3576h0000gn/T/pip-build-8vj20eqa/mysqlclient/setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "/private/var/folders/d9/z3yxpfl505s_jwtty_x3576h0000gn/T/pip-build-8vj20eqa/mysqlclient/setup_posix.py", line 26, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
OSError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/d9/z3yxpfl505s_jwtty_x3576h0000gn/T/pip-build-8vj20eqa/mysqlclient/
I hope someone can help me get past this since I'm definitely stuck at this point. Thank you in advance!
-b
I think you have issue in your Mysql connectors.. so try these,
sudo apt-get install mysql-server
mysql-config is in a different package, which can be installed from:
sudo apt-get install libmysqlclient-dev
This was the clue, unfortunately, I understood it after I posted my question:
/bin/sh: mysql_config: command not found
I thought that the path to the MySQL executables was correct, but it wasn't. I added this to my .bash_profile file:
export PATH=$PATH:/usr/local/mysql/bin
and then changed the ENGINE setting in settings.py back to:
'ENGINE': 'django.db.backends.mysql',
..and the migrations went fine.

Install Specific PHP Version with Puppet & Vagrant

First time puppet user, and I'm having trouble getting an install of a specified version of PHP using Vagrant. I'm using the example42/php module, and I keep running into ensure problems.
Error: Could not update: Execution of '/usr/bin/yum -d 0 -e 0 -y install php-5.5.12' returned 1: Error: Nothing to do
Error: /Stage[main]/Php/Package[php]/ensure: change from absent to 5.5.12 failed: Could not update: Execution of '/usr/bin/yum -d 0 -e 0 -y install php-5.5.12' returned 1: Error: Nothing to do
Warning: /Stage[main]/Php/File[php.conf]: Skipping because of failed dependencies
spits out of my console, followed by another attempt that's identical.
My .pp file I'm provisioning with:
class lamp {
# package {'php':
# ensure => present,
# }
}
node 'node1' {
include lamp
file { '/php':
ensure => directory,
# I read that I may need to have a directory in order for the install to work...
}
class { 'php':
version => '5.5.12',
}
}
As far as I can tell, I'm referencing correctly to the modules, which I store inside /puppet/modules/ and it's finding them, but I'm having a hard time getting a specific version of PHP to install. I could use a very simple "getting started LAMP" for Puppet but that only install 5.3.3 even if I ensure => latest,
The puppet module only uses your system's package manager (yum) to download specific php packages. If it cannot find the required packages, it will not work. 5.3.3 is latest version in your repository, so it install that. I wouldn't be surprised if this is the only version of php available in your repositories.
You need to configure yum with some repositories which have the required PHP packages and then try the puppet module with that.

How to install a project using symfony

I am trying to install on my local machine the following project connect which is using symfony2.
I did perform the following commands:
cd myWebDirectory
git clone git://github.com/dsyph3r/connect
git submodule update --init
When I try to call the following page from my localhost I get the following error:
http://localhost/~myName/connect/web/app_dev.php
Server error
If I look to the logs file of apache I read:
PHP Fatal error: require_once():
Failed opening require
'/Users/myName/Sites/connect/app/../vendor/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php'
How should I install the vendor?
What I did miss?
You forgot to install the vendor ("third party") libraries.
php bin/vendor install
Update: It's a while ago, since I wrote this and it's not valid anymore (for new(er) projects). Since 2.1 it uses Composer
php composer.phar install

Getting codeception & phpunit working on MAMP with OS X Lion

Running:
MAMP 2.0.5
PHP 5.3.6 (bundled with MAMP)
Mac OS X Lion 10.7.2
My goal is to get the Codeception testing framework to work and use within my MAMP project. I'm following the instructions here on how to install it.
Pear is installed and working fine. I am able to get Codeception installed with these commands:
$ pear channel-discover codeception.com/pear
$ pear install codeception/Codeception
Once installed when I try to run the codecept commands I get the following error:
Warning: require_once(Codeception/autoload.php): failed to open stream: No such file or directory in /usr/bin/codecept on line 12
Fatal error: require_once(): Failed opening required 'Codeception/autoload.php' (include_path='.:') in /usr/bin/codecept on line 12
I think that the issue is caused by either:
A conflict between MAMP's PHP installation in the one bundled with OS X
An issue with the include_path in my php.ini or somewhere else
Also of interest
When I run the $ phpunit command from inside my project folder I get -bash: phpunit: command not found but if I run it as $ /Applications/MAMP/bin/php/php5.3.6/bin/phpu
nit it works just fine.
I would expect there to be a codecept file in /Applications/MAMP/bin/php/php5.3.6/bin/ but there isn't - there is however a Codeception folder in /Applications/MAMP/bin/php/php5.3.6/lib/php
I've tried a few different ways to install it, and I guess one of the ways installed Codeception in Lion's copy of php (as opposed to MAMP's) - so I do have a codecept file in /usr/bin/ as well as the Codeception folder in /usr/lib/php/pear/
For reference:
PHP lives here: /Applications/MAMP/bin/php/php5.3.6/bin/php
Pear lives here: /Applications/MAMP/bin/php/php5.3.6/bin/pear
PHPUnit lives here: /Applications/MAMP/bin/php/php5.3.6/bin/phpunit
Any Help? Suggestions?
Thanks to Davert's help - I was able to confirm that this is a conflict with MAMP's copy of PHP and Lion's built-in copy of PHP. To solve the issue I created a new php.ini file in /etc that was a duplicate of php.ini.default and changed the include_path to /Applications/MAMP/bin/php/php5.3.6/lib/php
I think the problem is: your PEAR command was executed from bundled PHP. So your primary MAMP PHP libraries in (/Applications/MAMP/bin/php/php5.3.6/bin/pear) were not updated. I suggest you should find the second PEAR were the Codeception was exctually stored. And add path to it into 'include_path' in php.ini.
Yes, PEAR is quite buggy. In next releases a Composer installator will be added.
Also, you can try to use Phar executable.
In this case a Codeception should be executed with:
php codecept.phar
One solution that worked for me was to edit /Applications/MAMP/bin/php5.3/bin/codecept and replace /usr/bin/php at the first line by /Applications/MAMP/bin/php5.3/bin/php

Categories