title: How to connect AS400 with Laravel
body: <p>For a little while now, I've been looking how to try a connection to AS400 with Laravel 7.</p>
  
  <p>I use this package : <a href="https://github.com/cooperl22/laravel-ibmi" rel="nofollow noreferrer">https://github.com/cooperl22/laravel-ibmi</a></p>
  
  <p>I add laravel-ibmi to your composer.json file:</p>
  
  <pre><code>"require": {
      "cooperl/laravel-ibmi": "^7.0"
  }
  </code></pre>
  
  <p>Use composer to install this package.</p>
  
  <pre><code>$ composer update
  </code></pre>
  
  <p>Run on the command line from the root of my project:</p>
  
  <pre><code>$ php artisan vendor:publish
  
  </code></pre>
  
  <p>And set credentials in .env</p>
  
  <pre><code>DB_CONNECTION=ibmi
  DB_HOST=********
  DB_PORT=********
  DB_DATABASE=********
  DB_USERNAME=********
  DB_PASSWORD=********
  </code></pre>
  
  <p>I try a connection with tinket but i have this message :</p>
  
  <pre><code>Psy Shell v0.10.4 (PHP 7.2.24-0ubuntu0.18.04.4 — cli) by Justin Hileman
  &gt;&gt;&gt; DB::connection();
  PDOException with message 'could not find driver
  </code></pre>
  
  <p>I should set my credentials in app/config/db2.php, not in .env ?</p>
  
  <p>UPDATE</p>
  
  <p>I install the unixODBC</p>
  
  <pre><code>odbcinst -j
  unixODBC 2.3.4
  DRIVERS............: /etc/odbcinst.ini
  SYSTEM DATA SOURCES: /etc/odbc.ini
  FILE DATA SOURCES..: /etc/ODBCDataSources
  USER DATA SOURCES..: /home/za/.odbc.ini
  SQLULEN Size.......: 8
  SQLLEN Size........: 8
  SQLSETPOSIROW Size.: 8
  
  </code></pre>
  
  <p>Download ibm_data_server_driver_for_odbc_cli_linux390x64_v11.5.tar.gz</p>
  
  <pre><code>tar -xavf ibm_data_server_driver_for_odbc_cli_linux390x64_v11.5.tar.gz
  cd odbc_cli
  sudo mkdir -p /opt/ibm/clidriver
  sudo cp -r clidriver/* /opt/ibm/clidriver
  </code></pre>
  
  <p>Edit the odbcinst.ini </p>
  
  <pre><code>[Db2]
  Description=Db2 Driver
  Driver=/opt/ibm/clidriver/lib/libdb2o.so
  fileusage=1
  dontdlclose=1
  
  </code></pre>
  
  <p>Edit odbc.ini for the test</p>
  
  <pre><code>[sample]
  Description     = Test to DB2
  Driver          = Db2
  </code></pre>
  
  <p>but when i try i got this message</p>
  
  <pre><code>export DB2INSTANCE=db2inst1
  isql -v sample db2inst1 ibmdb2
  [01000][unixODBC][Driver Manager]Can't open lib '/opt/ibm/clidriver/lib/libdb2o.so' : file not found
  [ISQL]ERROR: Could not SQLConnect
  </code></pre>
  
  <p>UPDATE 2</p>
  
  <p>I go to <a href="https://www.ibm.com/support/pages/node/633843" rel="nofollow noreferrer">https://www.ibm.com/support/pages/node/633843</a></p>
  
  <p>Click Downloads for IBM i Access Client Solutions</p>
  
  <p>When prompted, log in with my IBMid</p>
  
  <p>Scroll down, and next to ACS Linux App Pkg, select Download now</p>
  
  <p>After that i have installed ibm-iaccess-1.1.0.13-1.0.x86_64.rpm, i see it automatically adds the IBM i Access ODBC Driver to odbcinst.ini.</p>
  
  <p>Edit odbc.ini for the test</p>
  
  <pre><code>[sample]
  Description     = Test to DB2
  Driver          = IBM i Access ODBC Driver
  </code></pre>
  
  <p>But it's the bug is repeated (Whereas /opt/ibm/iaccess/lib64/libcwbodbc.so exist). </p>
  
  <pre><code>isql -v sample
  [01000][unixODBC][Driver Manager]Can't open lib '/opt/ibm/iaccess/lib64/libcwbodbc.so' : file not found
  [ISQL]ERROR: Could not SQLConnect
  </code></pre>
  
  <p>UPDATE 3</p>
  
  <p>I enter this command </p>
  
  <pre><code>ldd /opt/ibm/iaccess/lib64/libcwbodbc.so
      linux-vdso.so.1 (0x00007ffe4830e000)
      libodbcinst.so.2 =&gt; /usr/lib/x86_64-linux-gnu/libodbcinst.so.2 (0x00007f1fdc97e000)
      libcwbcore.so =&gt; not found
      libstdc++.so.6 =&gt; /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f1fdc5f5000)
      libm.so.6 =&gt; /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1fdc257000)
      libgcc_s.so.1 =&gt; /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f1fdc03f000)
      libc.so.6 =&gt; /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1fdbc4e000)
      libltdl.so.7 =&gt; /usr/lib/x86_64-linux-gnu/libltdl.so.7 (0x00007f1fdba44000)
      libpthread.so.0 =&gt; /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f1fdb825000)
      /lib64/ld-linux-x86-64.so.2 (0x00007f1fdce6c000)
      libdl.so.2 =&gt; /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1fdb621000)
  
  </code></pre>
  
  <p>I did that afterwards.</p>
  
  <pre><code>cp /opt/ibm/iaccess/lib64/libcwbcore.so /usr/lib/x86_64-linux-gnu/
  </code></pre>
  
  <pre><code>isql -v sample
  [S1000][unixODBC][IBM][Pilote ODBC System i Access]Le nom de syst�me requis pour la connexion est manquant.
  [ISQL]ERROR: Could not SQLConnect
  </code></pre>