connection laravel and oracle by yajra - php

I almost gave up, before there is no problem but after I reinstall the oracle why laravel can't connect.
This error as I can when running the migrate:
c:\xampp\htdocs\tester>php artisan migrate
[Yajra\Pdo\Oci8\Exceptions\Oci8Exception]
ORA-24315: illegal attribute type
file .env ->
DB_CONNECTION=oracle
DB_HOST=127.0.0.1
DB_PORT=1521
DB_DATABASE=corsys
DB_USERNAME=tester
DB_PASSWORD=orcl
oracle.php in the folder config ->
<?php
return [
'oracle' => [
'driver' => 'oracle',
'tns' => env('DB_TNS', ''),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '1521'),
'database' => env('DB_DATABASE', 'corsys'),
'username' => env('DB_USERNAME', 'tester'),
'password' => env('DB_PASSWORD', 'orcl'),
'charset' => env('DB_CHARSET', 'AL32UTF8'),
'prefix' => env('DB_PREFIX', ''),
'prefix_schema' => env('DB_SCHEMA_PREFIX', ''),
],
];
please help me :(

You need to enable your oracle driver for PHP to be able to access your oracle database.
Related answer here:
https://stackoverflow.com/a/26213384/1739852

Related

laravel 5.6 SQLSTATE[HY000] [2002] connection refused on freash install

I'm trying to setup a new laravel 5.6 project and I'm currently having issues with getting the database migrated. I've fiddled with the hosts names from localhost to 127.etc and the box IP. After creatingthe auth blades I can't create a new user I receive a
SQLSTATE[HY000] [2002] connection refused error.
I have attempted to log into the box to see what's in the database but I get the same error when I connect with the default homestead U&P. I also tried root/root but received the same error.
Here is part DB config
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
'redis' => [
'client' => 'predis',
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
try it : 'strict' => true, To strict' => false, in DB config Part
I ended up sshing into the homestead vagrant box and running 'artisan migrate:install' which solved the bulk of my problems. I then had to create a database schema partially generated by laravel and the rest edited by myself.

Laravel 5.0 Auth uses Homestead instead of .env DB

I've setup Laravel 5.0 (that's a requirement) and set it up to use remote MySQL DB. All migrations and data interactions pass OK, but when trying to use Auth login POST, it fails with PDOException in Connector.php line 47:
SQLSTATE[HY000] [2002] No such file or directory, mentioning " PDO->__construct('mysql:host=localhost;dbname=homestead', 'homestead', 'secret', array('0', '2', '0', false, false))"
WHERE did it take that homestead DSN? Why does it skip the database.php config and .env config? If I try to add to .env some socket info (well it should not count here, right?) the socket path passes to the mentioned PDOException call stack, but hostname, login etc. NOT!
Confused. What am I doing wrong?
UPD
Here's the .env:
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString
DB_HOST=mysql.someremteohosting.net
DB_DATABASE=mydb
DB_USERNAME=myuser
DB_PASSWORD=mysuperpassword
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
And here's database.php:
<?php
return [
'fetch' => PDO::FETCH_CLASS,
'default' => 'mysql',
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => storage_path().'/database.sqlite',
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'prefix' => '',
],
],
'migrations' => 'migrations',
],
];
Again, all migrations work. I can create, save and fetch objects in tinker without any problem. The only reference to homestead is in .env.example file.
Not sure what exactly was wrong here. The only place where I found 'homestead' in the app code was in .env.example. I deleted it an ran composer dump-autoload. After that it worked. Still surprised about laravel lurking into .example config without any reason.

Illegal string offset on heroku deployment

I am configuring my postgresql driver in Laravel 5.4 for deployment to Heroku. Here is my config/database.php, the default is already set to pgsql
'pgsql' => [
'driver' => 'pgsql',
'host' => parse_url(getenv("DATABASE_URL"))['host'],
'database' => substr(parse_url(getenv("DATABASE_URL"))['path'], 1),
'username' => parse_url(getenv("DATABASE_URL")['username']),
'password' => parse_url(getenv("DATABASE_URL")['password']),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
],
When I commit I see this warning
PHP Warning: Illegal string offset 'username' in app/config/database.php on line 62
When run heroku run php artisan serveI am getting an error
[Symfony\Component\Debug\Exception\FatalThrowableError]
Type error: PDO::__construct() expects parameter 2 to be string, array given
Here is my .env
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=forge
DB_USERNAME=postgres
DB_PASSWORD=
Your configuration array should look like the following if you want to get correct data from the .env provided.
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer',
]
I found the answer in this site. It caters also mysql, and sqlite, please read
https://mattstauffer.co/blog/installing-a-laravel-app-on-heroku

Laravel switch mysql to mongodb

After completed my project I deiced switch mysql to mongodb. I am using Laravel 5.4 version and for mongodb use jenssegers. For laravel mongdb installation I follow jenssegers installation documentations and installation successfully completed. But after installation I go for migration and use command php artisan migrate. When I use this command shown error InvalidArgumentException in /vendor/mongodb/mongodb/src/Database.php line 83: $databaseName is invalid:
My database.php
'default' => env('DB_CONNECTION', 'mongodb'),
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer',
],
'mongodb' => [
'driver' => 'mongodb',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 27017),
'database' => env('DB_DATABASE', 'project_db'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'options' => [
'database' => 'admin' // sets the authentication database required by mongo 3
]
],
],
My .env
DB_CONNECTION=mongodb
DB_HOST=localhost
DB_PORT=27017
DB_DATABASE=admin
DB_USERNAME=
DB_PASSWORD=
And I also facing one more problem if whatever I change in .env and database.php like if I change port 27017 to 3303 but on browser shows 27017. I cleared cache and all. I don't know what is problem in my code.
These are the steps Envoyer (made by Laravel's creator) takes to deploy an app on production -- I've annotated them below:
# Clear the old boostrap/cache/compiled.php
php artisan clear-compiled
# Recreate boostrap/cache/compiled.php
php artisan optimize
# Migrate any database changes
php artisan migrate

Laravel 5.2 oracle database PDOException

I am working on xamp, using laravel 5.2 and trying to connect oracle database
here I want to get values in tinker:
DB::table('dept')->get();
with this error:
PDOException with message 'could not find driver'
my .env file
DB_CONNECTION=sqlsrv
DB_HOST=localhost
DB_PORT=1521
DB_DATABASE=Mydb
DB_USERNAME=db_username
DB_PASSWORD=password
my database.php
'default' => env('DB_CONNECTION', 'sqlsrv'),
...
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'Mydb'),
'username' => env('DB_USERNAME', 'db_username'),
'password' => env('DB_PASSWORD', 'password'),
'charset' => 'utf8',
'prefix' => '',
],
Install Oracle client in your machine: http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
Install/enable Oracle for PHP. That will depend on your operation system. In windows, I believe you only need to enable on your php.ini, extension=pdo_oci.dll. In linux, you need to install, with apt get or similar in your distro, or recompile PHP with instructions on this page: http://php.net/manual/en/ref.pdo-oci.php
Use this library in your Laravel project: https://github.com/yajra/laravel-oci8
In config/database.php:
'default' => env('DB_CONNECTION', 'my_connection'),
'connections' => [
'my_connection' => [
'driver' => 'oracle',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1521'),
'service_name' => env('DB_SERVICE_NAME', ''),
'database' => env('DB_DATABASE', ''),
'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'options' => [
PDO::ATTR_PERSISTENT => true
],
],
In your .env:
DB_CONNECTION=my_connection
DB_HOST=111.111.111.111
DB_SERVICE_NAME=service
DB_DATABASE=db
DB_USERNAME=user
DB_PASSWORD=pass

Categories