s2i-php-container
s2i-php-container copied to clipboard
Run MongoClient on Openshift V3
Hi, when lunch my application return this error:
"Class 'MongoClient' not found in /opt/app-root/src"
So i changed to 'MongoDB\Driver\Manager' but the result is the same:
"Class 'MongoDB\Driver\Manager' not found"
There are modules: sh-4.2$ cd /opt/rh/rh-php70/root/usr/lib64/php/modules sh-4.2$ ls bcmath.so gd.so mysqlnd.so shmop.so wddx.so bz2.so gettext.so opcache.so simplexml.so xml.so calendar.so gmp.so pdo.so soap.so xmlreader.so ctype.so iconv.so pdo_mysql.so sockets.so xmlwriter.so curl.so intl.so pdo_pgsql.so sqlite3.so xsl.so dom.so json.so pdo_sqlite.so sysvmsg.so zip.so exif.so ldap.so pgsql.so sysvsem.so fileinfo.so mbstring.so phar.so sysvshm.so ftp.so mysqli.so posix.so tokenizer.so
why mongodb.so is not installed on server? what is the correct way?
Thanks
@maicolcantagallo More info about adding mongodb driver can be found in https://github.com/sclorg/s2i-php-container/pull/169
Thanks @omron93 but i did not understand how to make the configuration. I've created a source code pods and a mongodb storage pods. Am I doing something wrong?
Thanks @omron93 but i did not understand how to make the configuration. I've created a source code pods and a mongodb storage pods. Am I doing something wrong?
I think you do it right. Mongo driver has to be somehow installed in your source code pod to be able to access database.
thanks @omron93 but I do not understand how to install mongo db inside the pod. when i lunch command pecl install mongodb-1.3.0 return Cannot install, php_dir for channel "pecl.php.net" is not writeable by the current user
@maicolcantagallo As a quick work around, please see the below instructions for using a PHP S2I image that I had created specifically to include the mongodb drivers. This is a workaround until I can update #169 to allow users to pecl install
themselves.
In the web console, go to Builds > Builds. Click on the name of your application, and then under Actions, select Edit. Next change Build From to "Docker Image", and specify the following image depending on your version of PHP:
-
wgordon/openshift-s2i-php-56:latest
for PHP 5.6 -
wgordon/openshift-s2i-php-70:latest
for PHP 7.0
Then hit save! That's it. This is also assuming that you already have a composer.json file that includes "mongodb/mongodb". You can see an example of that here.
thanks @wgordon17 . do I have to import Docker Image source into my php source codes or do I have to insert an external path?
When start build application return this error
Pulling image "maicolcantagallo/s2i-php-container/7.0" ... pulling image error : unauthorized: authentication required error: build error: unable to get maicolcantagallo/s2i-php-container/7.0:latest
Hi @maicolcantagallo, you don't have to import it at all, you can just change the Build From
value. Also, you have to specify Docker Image
and use "wgordon" to pull from my DockerHub account
Thanks @wgordon17 . Now return this error
Pulling image "wgordon/openshift-s2i-php-70:latest" ... pulling image error : manifest unknown: manifest unknown error: build error: unable to get wgordon/openshift-s2i-php-70:latest
Sorry, i was wrong to choose php version
First step it's ok. Where is composer.json? I can't find it in my source
@maicolcantagallo It's a file to tell Composer what dependencies are necessary to install. In the case of MongoDB, you need both the drivers (solved with my custom Docker image), and the extensions (solved by Composer).
Your composer.json file can be a very simple
{
"require": {
"mongodb/mongodb": ">=1.0"
}
}
Add that to your git source, and re-build. The PHP S2I image handles the rest!
now works fine!
Thanks @wgordon17
sorry @wgordon17 another question. If i want to use MongoClient instead of MongoDB\Driver\Manager is possibile?
Thanks
@maicolcantagallo MongoClient has been deprecated, I'm not familiar enough with it to know how to install it. Sorry
Since MongoClient has been deprecated, then I am closing this issue. Feel free to reopen it in case it is still valid.