title: Codeigniter - 4 how to access/load packages from vendor folder on a shared hosting server
body: <p>I have an application based on codeigniter 4, developed locally with vagrant and VirtualBox VM.
  Then I moved it to a shared hosting environment, that is based on litespeed server and cpanel.</p>
  <p>The application use certain external packages like phpmailer, sendgrid and google oauth that on local development environment I have installed them with composer. Therefore they were installed in the vendor folder by composer.</p>
  <p>When switching to the shared hosting  i have moved the codeigniter installation from the public_html folder one level up, in a dedicated folder called ci4, and as instructed by the documentation I have changed in the index.php front controller the $pathsConfig variable indicating the new folder of ci4 installation.</p>
  <p>On the shared hosting server I do not have access to the composer and I just copied the vendor folder from the local computer to the shared server (in the ci4 folder).</p>
  <p>The application run well until the moment I use a helper that has a function for sending e-mail based on the PHPMailer external package. I am receiving a <em>Class 'PHPMailer\PHPMailer'</em> not found error.
  It seems that the application cannot locate de PHPMailer package.
  The helper look like this:</p>
  <pre><code>require_once ROOTPATH . 'vendor/autoload.php';
  
  use PHPMailer\PHPMailer;
  use PHPMailer\Exception;
  
  function send_email($email, $subject, $body, $altbody)
  {
     
      $config = config(&quot;Custom&quot;);
      try {
          $mail = new PHPMailer(true);
          // Server Settings
          $mail-&gt;isSMTP();
          $mail-&gt;SMTPDebug = 0; // change this to 0 in production environment
          $mail-&gt;Timeout = 30;
          $mail-&gt;Host = 'email-smtp.eu-central-1.amazonaws.com';
          $mail-&gt;Port = '587';
          $mail-&gt;SMTPAuth = true;
          $mail-&gt;Username = $config-&gt;aws_smtp_user; 
          $mail-&gt;Password = $config-&gt;aws_smtp_password; 
          $mail-&gt;SMTPSecure = 'tls';
          //$mail-&gt;SMTPAutoTLS = false;
  
          // Recipients
          $mail-&gt;setFrom($email, 'Contact Form');
          $mail-&gt;addAddress('example@domain.com');
  
          // Content
          $mail-&gt;Subject = $subject;
          $mail-&gt;msgHTML($body);
          $mail-&gt;AltBody = $altbody;
          $mail-&gt;send();
          return [&quot;flag&quot; =&gt; true];
      } catch (Exception $e) {
          //print_r($mail-&gt;ErrorInfo);
          return [&quot;flag&quot; =&gt; false, &quot;error&quot; =&gt; $mail-&gt;ErrorInfo];
      }
  }
  </code></pre>
  <p>The helper is loaded automatically in the BaseController using the protected $helper variable.</p>
  <p>In the Autoload.php config file I have added the PHPMailer source folder to $psr4 variable</p>
  <pre><code>public $psr4 = [
          APP_NAMESPACE =&gt; APPPATH, // For custom app namespace
          'Config'      =&gt; APPPATH . 'Config',
          'PHPMailer' =&gt; ROOTPATH . 'vendor/phpmailer/phpmailer/src/'
          ];
  </code></pre>
  <p>So my first question is, if on a shared hosting copying the vendor is a good approach or do I need to have access to composer and to run <em>composer install</em> command?</p>
  <p>If I can copy vendor folder why codeigniter 4 does not sees the third packages located in this folder and how can I solve this issue?</p>
  <p>My folder structure is the following:</p>
  <pre><code> /home
      bin
      /ci4
        app
        tests
        vendor
        writable
        .env
        .composer.json
        .composer.lock
      etc
      logs
      /public_html
         css
         images
         js
         webfonts
         .htaccess
         index.php
      public_ftp
      tmp
      var   
  </code></pre>
  <p>Many thanks!</p>