Giter VIP home page Giter VIP logo

Comments (15)

yajra avatar yajra commented on July 17, 2024 1

Hi! Just experienced this issue today while setting up homestead with php5-fpm. The solution for this was to add extension=oci8.so on /etc/php5/cli/php.ini. Finally found it after an hour of researching and no luck finding anything that works. This was just a wild guess using trial and error but it works. It appears that cli have different php.ini than the fpm/web config.

from laravel-oci8.

yajra avatar yajra commented on July 17, 2024

You don't need to install PDO_OCI.

Question: Does Laravel works when you access it on the browser? Try testing the connection on a test route. If it works then the problem must be on your PHP CLI configuration.

Route::get('test', function() {
    dd (DB::connection()->getPdo());
});

from laravel-oci8.

yajra avatar yajra commented on July 17, 2024

Also check your PHP CLI environment. Most probably, you have multiple php installations? Try running php -v and which php to verify if you have the correct settings.

from laravel-oci8.

rgiaviti avatar rgiaviti commented on July 17, 2024

Hi! Thanks for the answers! I have installed PHP with sudo apt-get install php5-cli php5-fpm (PHP is running as FastCGI). Besides php5-fpm and php5-cli, I uinstalled a lot of other libraries. If I run php -v:

rgiaviti@unformint ~ $ php -v
PHP 5.6.5-1+deb.sury.org~trusty+1 (cli) (built: Jan 26 2015 11:42:37)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
rgiaviti@unformint ~ $

About your second question, yes, it works when I access on the browser. I just changed your code to specify my Oracle connection (not my default connection):

Route::get('test', function() {
    dd(DB::connection('e1')->getPdo());
});

When I accessed on the browser, no error has been shown. Output:

object(yajra\Pdo\Oci8)[218]
  public '_dbh' => resource(4, oci8 connection)
  protected '_options' => 
    array (size=4)
      8 => int 2
      3 => int 2
      11 => int 0
      'charset' => string 'AL32UTF8' (length=8)
  protected '_inTransaction' => boolean false
  protected '_table' => null

To provide more details about this problem, here is the seed that when I run, raises the problem shown. In my seed, I connect in a Oracle database, query against it, get the data and insert into my default database (pgsql).

public function run() {
    DB::transaction(function() {
        DB::table('activities')->delete();

        $e1Activities = DB::connection('e1')->select('SELECT * FROM vw_activities');

        foreach($e1Activities as $e1Atv) {
            $poAtv = array('code' => trim($e1Atv->code),
                           'desc' => trim($e1Atv->desc),
                           'type' => $e1Atv->type,
                           'codeu' => $e1Atv->codeu,
                           'codedir' => $e1Atv->codedir,
                           'sigdir' => $e1Atv->sigdir,
                           'codeemp' => $e1Atv->codeemp,
                           'codetec' => $e1Atv->codetec,
                           'active' => $e1Atv->active,
                           'conv' => trim($e1Atv->conv),
                           'user' => trim($e1Atv->user),
                           'codemas' => $e1Atv->codemas,
                           'date' => $e1Atv->date);

            DB::table('activities')->insert($poAtv);
        }
    });
}

from laravel-oci8.

rgiaviti avatar rgiaviti commented on July 17, 2024

Hi! More details. Maybe can help.

I tried to run the same command in another enviroment (my work - Linux Mint also and Windows 7 64 bits with Xampp). Same problem. On Windows machine, I collected the stacktrace (below). Now I don't know if this is a bug or if there is a problema with my project. :(

The error occurs exactly on this line in the seeder: DB::connection('e1')->select('SELECT * FROM vw_atividade'); But, if I use my default connection, for exemple, DB::select('select * from table');, it works fine!

[2015-02-02 15:02:06] production.ERROR: exception 'yajra\Pdo\Oci8\Exceptions\Oci8Exception' in C:\Desenvolvimento\xampp\htdocs\po\vendor\yajra\laravel-pdo-via-oci8\src\yajra\Pdo\Oci8.php:88
Stack trace:
#0 C:\Desenvolvimento\xampp\htdocs\po\vendor\yajra\laravel-oci8\src\yajra\Oci8\Connectors\OracleConnector.php(41): yajra\Pdo\Oci8->__construct('(DESCRIPTION = ...', 'dta', 'dta', Array)
#1 C:\Desenvolvimento\xampp\htdocs\po\vendor\yajra\laravel-oci8\src\yajra\Oci8\Connectors\OracleConnector.php(56): yajra\Oci8\Connectors\OracleConnector->createConnection('(DESCRIPTION = ...', Array, Array)
#2 C:\Desenvolvimento\xampp\htdocs\po\vendor\yajra\laravel-oci8\src\yajra\Oci8\Oci8ServiceProvider.php(47): yajra\Oci8\Connectors\OracleConnector->connect(Array)
#3 [internal function]: yajra\Oci8\Oci8ServiceProvider->yajra\Oci8\{closure}(Array, 'e1')
#4 C:\Desenvolvimento\xampp\htdocs\po\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php(173): call_user_func(Object(Closure), Array, 'e1')
#5 C:\Desenvolvimento\xampp\htdocs\po\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php(64): Illuminate\Database\DatabaseManager->makeConnection('e1')
#6 C:\Desenvolvimento\xampp\htdocs\po\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php(208): Illuminate\Database\DatabaseManager->connection('e1')
#7 C:\Desenvolvimento\xampp\htdocs\po\app\database\seeds\admin\TabelaAtividadesSeeder.php(23): Illuminate\Support\Facades\Facade::__callStatic('connection', Array)
#8 C:\Desenvolvimento\xampp\htdocs\po\app\database\seeds\admin\TabelaAtividadesSeeder.php(23): Illuminate\Support\Facades\DB::connection('e1')
#9 C:\Desenvolvimento\xampp\htdocs\po\vendor\laravel\framework\src\Illuminate\Database\Connection.php(458): TabelaAtividadesSeeder->{closure}(Object(Illuminate\Database\PostgresConnection))
#10 [internal function]: Illuminate\Database\Connection->transaction(Object(Closure))
#11 C:\Desenvolvimento\xampp\htdocs\po\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php(321): call_user_func_array(Array, Array)
#12 C:\Desenvolvimento\xampp\htdocs\po\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php(208): Illuminate\Database\DatabaseManager->__call('transaction', Array)
#13 C:\Desenvolvimento\xampp\htdocs\po\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php(208): Illuminate\Database\DatabaseManager->transaction(Object(Closure))
#14 C:\Desenvolvimento\xampp\htdocs\po\app\database\seeds\admin\TabelaAtividadesSeeder.php(42): Illuminate\Support\Facades\Facade::__callStatic('transaction', Array)
#15 C:\Desenvolvimento\xampp\htdocs\po\app\database\seeds\admin\TabelaAtividadesSeeder.php(42): Illuminate\Support\Facades\DB::transaction(Object(Closure))
#16 C:\Desenvolvimento\xampp\htdocs\po\vendor\laravel\framework\src\Illuminate\Database\Seeder.php(37): TabelaAtividadesSeeder->run()
#17 C:\Desenvolvimento\xampp\htdocs\po\app\database\seeds\DatabaseSeeder.php(15): Illuminate\Database\Seeder->call('TabelaAtividade...')
#18 C:\Desenvolvimento\xampp\htdocs\po\vendor\laravel\framework\src\Illuminate\Database\Console\SeedCommand.php(57): DatabaseSeeder->run()
#19 C:\Desenvolvimento\xampp\htdocs\po\vendor\laravel\framework\src\Illuminate\Console\Command.php(112): Illuminate\Database\Console\SeedCommand->fire()
#20 C:\Desenvolvimento\xampp\htdocs\po\vendor\symfony\console\Symfony\Component\Console\Command\Command.php(253): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 C:\Desenvolvimento\xampp\htdocs\po\vendor\laravel\framework\src\Illuminate\Console\Command.php(100): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 C:\Desenvolvimento\xampp\htdocs\po\vendor\symfony\console\Symfony\Component\Console\Application.php(889): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 C:\Desenvolvimento\xampp\htdocs\po\vendor\symfony\console\Symfony\Component\Console\Application.php(193): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\SeedCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 C:\Desenvolvimento\xampp\htdocs\po\vendor\symfony\console\Symfony\Component\Console\Application.php(124): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 C:\Desenvolvimento\xampp\htdocs\po\artisan(59): Symfony\Component\Console\Application->run()
#26 {main} [] []

from laravel-oci8.

yajra avatar yajra commented on July 17, 2024

Hi,

The output on your browser indicates that oci8 is working properly. However, it is weird why oci_connect could not be found on the terminal. Were you able to setup the Oracle Environments?

Troubleshooting

The most common problem with installing OCI8 is not having the Oracle environment correctly set. This typically appears as a problem using oci_connect() or oci_pconnect(). The error may be a PHP error such as Call to undefined function oci_connect(), an Oracle error such as ORA-12705, or even an Apache crash. Check the Apache log files for startup errors and see the sections above to resolve this problem.

from laravel-oci8.

rgiaviti avatar rgiaviti commented on July 17, 2024

Well, after days working and researching about this issue, I think I got, at least, one conclusion: *Oracle is a Hell on Earth!

I have tested on two Linux Machines and one Windows Machine. All of them had the same problem. However, on my last try on Linux, I purged every PHP package, Apache and Oracle Client from my system. Completely clean.

Then, I downloaded Xampp for Linux and I enabled oci8 under xampp using default client that ships with xampp (version 11.2.0.3.0). Tested with <?php phpinfo(); ?> and it worked. Tested with php artisan db:seed and it WORKED!

Don't know why, but it worked. I think it's because Oracle Instant Client version, but I tried with versions 12, and 10 (both 32 and 64 bits). They didn't worked.

Well, now I will keep working with xampp.

from laravel-oci8.

yajra avatar yajra commented on July 17, 2024

Yeah, I agree that setting up oci8 is a bit frustrating. Been there on my first or so months working on php oracle and sort it out using Zend Server which works well out of the box just by enabling oci8 extension. ^_^

Anyways, good to know that you sort it out on Xampp. 🍻

from laravel-oci8.

rgiaviti avatar rgiaviti commented on July 17, 2024

Thank you! Today I setup a new enviroment for a new project and I experienced this issue again. I created a new file named 20-oci.ini under /etc/php5/cli/conf.d and added your suggested content to it: extension=oci8.so and worked like a charm. Thank you very much!

from laravel-oci8.

rgiaviti avatar rgiaviti commented on July 17, 2024

Well, the error always occurs when I use command line tools, like migrate or seed. So, when I use php artisan migrate, for example, I think the system is using the cli php.ini and not fpm. This explains why was not finding oci_connect() function.

from laravel-oci8.

yajra avatar yajra commented on July 17, 2024

Yes, I can confirm that CLI have different config than fpm. BTW, if you're still having problems on your environment, try using my version of homestead-oracle. This is what I am using for my development and I do not encounter errors like this so far.

from laravel-oci8.

rafatv avatar rafatv commented on July 17, 2024

Hi everybody. I recently installed this library using WAMP. I spent almost two days trying to configurate it, but the error wasn't in the library. The thing is that WAMP has TWO php.ini files. The one you choose from the icon in your System Tray is the file in php folder, but also you have to uncomment the "extension=php_oci8_11g.dll" in the php.ini found in the apache/bin folder so you can use artisan in your CLI.
Hope this save time to many people ;)

from laravel-oci8.

amrigo avatar amrigo commented on July 17, 2024

May it fix: http://stackoverflow.com/questions/34415833/laravel-call-to-undefined-function-yajra-pdo-oci-connect

from laravel-oci8.

Tugsbayar avatar Tugsbayar commented on July 17, 2024

I have a same issue. I use following requirement:

"require": {
        "laravel/framework": "4.2.11",
        "yajra/laravel-oci8": "1.*",
}

Is the version 1.* compatible with php 5.6?

from laravel-oci8.

falahatiali avatar falahatiali commented on July 17, 2024

@yajra : yajra can i migrate in oracle ?
i work with oracle in laravel with ur packege and work corrrectly . now i want to create migrate and work with them . but i get this error :
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined function Yajra\Pdo\oci_connect()

from laravel-oci8.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.