title: Load composer scripts inside class or function
body: <p>Im trying to load a composer script into my class or function. But keeps getting the error:</p>
  
  <pre><code>Parse error: syntax error, unexpected 'use' (T_USE) in 
  </code></pre>
  
  <p>I have searched on Stack Overflow and Google and read something about namespaces? But how can I implement a composer script into a class or function?</p>
  
  <p>function.php, loads the autoload.php script file:</p>
  
  <pre><code> require(TEMPLATEPATH.'/vendor/autoload.php');
  </code></pre>
  
  <p>Custom function script:</p>
  
  <pre><code>function addToMailchimp($email) {
  
  
    use \DrewM\MailChimp\MailChimp;
  
    $MailChimp_api_key = get_field('mailchimp_api_key', 'option');
    $MailChimp_landings_page = get_field('mailchimp_landings_page', 'option');
    $MailChimp_landings_page_failed = get_field('mailchimp_landings_page_failed', 'option');
    $MailChimp = new MailChimp($MailChimp_api_key);
  
    if ($email != '') {
  
      $list_id = '06b233d443';
  
      $result = $MailChimp-&gt;post("lists/$list_id/members", [
          'email_address' =&gt; $email,
          'status'        =&gt; 'subscribed',
      ]);
  
      if ($result['detail'] == '') {
          header( 'Location: ' . $MailChimp_landings_page['url']);
          exit;
      } else {
          header( 'Location: ' . $MailChimp_landings_page_failed['url']);
          exit;
      }
  
    }
  
  }
  </code></pre>
  
  <p>composer.json file:</p>
  
  <pre><code> {
   "require": {
       "drewm/mailchimp-api": "^2.5",
       "mpdf/mpdf": "^8.0"
   },
   "autoload": {
       "psr-4": {
         "DrewM\\MailChimp\\":"src/"
       }
    }
  }
  </code></pre>