I am getting this error:
MongoDB\Driver\Exception\InvalidArgumentException: Failed to parse MongoDB URI: 'mongodb://mongo:tcp://172.17.0.3:27017/mydatabase' in /var/www/laravel/vendor/mongodb/mongodb/src/Client.php:81
My enviroment variables look like this:
MONGO_DATABASE="mydatabase"
MONGO_HOST="mongo"
MONGO_PASSWORD=""
MONGO_PORT="27017"
MONGO_USERNAME=""
and my database.php looks like this
'mongodb' => [
'driver' => 'mongodb',
'host' => env('MONGO_HOST', 'localhost'),
'port' => env('MONGO_PORT', 27017),
'database' => env('MONGO_DATABASE', 'mydatabase'),
'username' => env('MONGO_USERNAME', ''),
'password' => env('MONGO_PASSWORD', ''),
'options' => [
'database' => 'admin' // sets the authentication database required by mongo 3
]
I can correctly ping mongo from the container and it resolves to 172.17.0.3 as per the connection string. It seems as if the rest of the connection string is not getting generated correct?
I am running Laravel 5.2 and my package.json has this entry
"mongodb/mongodb": "^1.0.0",
"jenssegers/mongodb": "3.0.*",
As per https://github.com/jenssegers/laravel-mongodb 3.0.X is highest compatibility for Laravel 5.2.
Many thanks in advance
After further investigation my link from Amazon ECS was passing another MONGO_PORT which was overriding the env set in my .env file.
Related
I am trying to connect django.db.backends.postgresql with my lumen application. But when I run the query then following error occured
could not find driver
Even I change the driver type from mysql to pgsql
My database connection
'ml_db' => [
'driver' => 'django.db.backends.postgresql',
'host' => env('ML_DB_HOST'),
'port' => env('ML_DB_PORT'),
'database' => env('ML_DB_NAME'),
'username' => env('ML_DB_USER'),
'password' => env('ML_DB_PASS'),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_COLLATION', 'utf8mb4_general_ci'),
'prefix' => '',
'timezone' => env('DB_TIMEZONE', '+00:00'),
'strict' => false,
],
Is there any way to connect this database with my lumen application because I am using multiple databases in application.
The obvious answer here is, that you haven't installed the corresponding driver for your used dbms. So just install it.
from your configuration posted in the question, I assume that it's your lumen configuration. There is no 'django.db.backends.postgresql' driver in lumen. What we have is pgsql driver unless you create such a custom driver yourself,(which I assume is not the case).
so change the driver parameter to the following?
'driver' => 'pgsql',
Lumen .env file:
DB_CONNECTION=pgsql
DB_HOST=your host
DB_PORT=5432
DB_DATABASE=database
DB_USERNAME=username
DB_PASSWORD=password
The link
Running Laravel 5.7 via Homestead.
This is happening in:
/vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php
"line":66
"function":"establishConnection"
We are using PHP Redis and in config/database.php:
'redis' => [
'client' => 'phpredis',
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 6,
],
],
I've seen other answers on here and none of the steps work. There is no redis cluster in use. PhpRedis extension is installed on VM and confirmed with php -m. Redis server is running at 127.0.0.1 and can be connected to outside of the code.
I'm unable to change the code as it works for others. It must be a configuration issue on my VM but I can't see what it could be. If anyone has had a similar issue I'd much appreciate any advice.
The problem you are having is because of class naming conflict: PhpRedisConnector creates new \Redis client, but it seems that you have alias for Illuminate\Support\Facades\Redis facade set up somewhere in your app. PhpRedisConnector creates new Redis and gets facade object instead.
Try removing this line in your config/app.php:
'aliases' => [
...
'Redis' => Illuminate\Support\Facades\Redis::class, // remove this line
...
]
I just installed Laravel 5.7 on my windows 7 machine and I want to use Sybase Central (v6.1) as my database but I can not seem to figure out how to connect to it.
I did a lot of google search but there is not much information out there when it comes to Sybase. This is what I'm trying but it does not work.
'connections' => [
'sybase' => [
'driver' => 'odbc',
'host' => env('DB_HOST', 'host-name'),
'port' => env('DB_PORT', 'port-number'),
'database' => env('DB_DATABASE', 'db-name'),
'username' => env('DB_USERNAME', 'user'),
'password' => env('DB_PASSWORD', 'password'),
'charset' => 'utf8',
'prefix' => '',
]
]
The error I get
InvalidArgumentException: Unsupported driver [odbc] in \vendor\laravel\framework\src\Illuminate\Database\Connectors\ConnectionFactory.php:283 Stack trace: #0
Does Laravel support Sybase or not?
Out of the box, Laravel doesn't look to support odbc, but there seems to be a package you can install to support it available at ODBC integration for Laravel Framework.
Simply follow the installation and usage guides on the page, and you should be able to use "driver" => "odbc" without issue.
From terminal run
composer require abram/laravel-odbc
Then configure the following files:
config/database.php
"connections" => [
"sybase" => [
"driver" => "odbc",
...
]
]
config/app.php
"providers" => [
...
Abram\Odbc\ODBCServiceProvider::class
]
I'm using laravel 5.2 with mongodb.
firstly I have created the laravel project using the command
composer create-project --prefer-dist laravel/laravel NC_Data
Then I have install the latest version of the mongodb package using the composer like:
composer require jenssegers/mongodb
Added the below line in config/app.php, in providers array:
Jenssegers\Mongodb\MongodbServiceProvider::class
and in the aliases array:
'Moloquent' => 'Jenssegers\Mongodb\Model'
below is the connections array in app/config/database.php, :
'mongodb' => array(
'driver' => 'mongodb',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 27017),
'database' => env('DB_DATABASE', 'dbname'),
'username' => env('DB_USERNAME', 'username'),
'password' => env('DB_PASSWORD', 'password'),
'options' => array(
'db' => 'admin' // sets the authentication database required by
mongo 3)
),
Also changed the default DB_Connection:
'default' => env('DB_CONNECTION', 'mongodb'),
When I run my project using CLI command of laravel i.e php artisan serve.It will run on port 8000 i.e http://localhost:8000/listing it works perfectly.But When try to run it using http://localhost/NC_Data/listing. NC_Data is my project folder,it gives me the below error:
FatalThrowableError in Connection.php line 149:
Class 'MongoClient' not found.
Can anybody please help me with this. Thanks in advance.
I am using laravel 5.2 and having an architecture of multi-server autoscaling. I want to have session and cache in a centralized location. I want to use AWS elasticache for the same.
I have setup an elasticache Redis cluster having following options :
Parameter group : default.redis.3.2.cluster.on
Shards : 3
Total Nodes : 9
In laravel session configuration I have set redis as the session driver.
In database.php where redis configuration is set, i have used following :
REDIS_HOST=my_aws_elasticache_configuration_endpoint
REDIS_PASSWORD=null
REDIS_PORT=6379
.
When I try to use it, I get following error :
MOVED 13841 some_ip_address_of_aws:6379
I tried using local redis and it worked, so predis is working properly. I tried to check the solutions online, but not able to get the solution. I believe that the configuration endpoint is trying to redirect the redis connection to an available node url out of the 9 nodes I have. However, I have anticipated that AWS should do it internally and not throw exception. Can anyone help me?
I finally got an answer, we need to get the cluster mode on in database settings and set new cluster option to redis. This is how the redis config in database.php looks like :
'redis' => [
'client' => 'predis',
'options' => [
'cluster' => 'redis',
],
'clusters' => [
'default' => [
[
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],
],
],
If you have password then you can replace options array with this :
'options' => [
'cluster' => 'redis',
'parameters' => ['password' => env('REDIS_PASSWORD', null)],
],