Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to connect to mongodb using php (Laravel)?

Mirko Tebaldi June 13, 2019

Actually I'm starting experimenting with this .yml I found in the internet

 

image: php:7.2

pipelines:
default:
- step:
caches:
- composer
script:
- apt-get update && apt-get install -y zlib1g-dev pkg-config libssl-dev openssl
- pecl install mongodb
- docker-php-ext-enable mongodb
- docker-php-ext-install zip
- docker-php-ext-enable zip
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- cp .env.testing .env
- composer install
- php artisan key:generate
- sleep 10
- vendor/bin/phpunit
services:
- mongo
definitions:
services:
mongo:
image: mongo

 

I think the problem is simply the url of the db server. How can I set the current ip of mongodb?

1) Tests\Unit\BrandTest::testMongoDB\Driver\Exception\ConnectionTimeoutException: 
No suitable servers found (`serverSelectionTryOnce` set):
[connection refused calling ismaster on '127.0.0.1:65231']

 

 

2 answers

1 accepted

0 votes
Answer accepted
Mirko Tebaldi June 25, 2019

I figured out that problem is that  we cannot configure mongo port. 

So I created a new mongo db connection in Laravel database.php config file where I am using standard port and (damn) no username and password and create a new .env.pipeline file.

In the yaml i force use of new mongo connection, specific for pipeline. 

At build time, I copy .env.pipeline as .env

0 votes
Lava Kumar Dukanam _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 17, 2019

Hi @Mirko Tebaldi ,

this could be of some help!

 

Thanks

Mirko Tebaldi June 25, 2019 edited

I figured out that problem is that (damn ,,, ) we cannot configure mongo port. 

 

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, forge, forge learning path, atlassian learning, cloud app development, forge app development, build forge apps, atlassian certification, developer training, jira app development, confluence app development, automation, ui frameworks

Turn Ideas into Atlassian Apps 📱

From setup to deployment—this learning path shows you how to build your first app using Forge. Learn the essentials, streamline workflows, and bring custom solutions to life across Jira, Confluence, and more.

Start Learning
AUG Leaders

Atlassian Community Events