CodeIgniter Forums
require vs use (neither working) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: require vs use (neither working) (/showthread.php?tid=78825)



require vs use (neither working) - richb201 - 03-15-2021

I am trying to include the following:

require 'vendor/Sendpulse/RestApi/ApiInterface.php";
require 'vendor/Sendpulse/RestApi/ApiClient.php';
require 'vendor/Sendpulse/RestApi/Storage/FileStorage.php';


I have tried it with "use" and also with require APPPath

But I am getting this error:

Severity: Compile Error
Message: require(): Failed opening required 'vendor/Sendpulse/RestApi/ApiInterface.php' (include_path='.:/opt/bitnami/php/lib/php')

Filename: controllers/Users_sendpulse.php
Line Number: 11



What am I doing wrong?


RE: require vs use (neither working) - John_Betong - 03-15-2021

Try echoing getcwd(); immediately before the first require_once(...):, and adjust the relative path to the directory where the classes are stored.


RE: require vs use (neither working) - kenjis - 03-15-2021

I recommend you read PHP manual.
https://www.php.net/manual/en/language.namespaces.importing.php

It seems sendpulse/rest-api is a composer package.
https://github.com/sendpulse/sendpulse-rest-api-php
If you install via composer, Composer autoloader autoload the files.
So you don't need to wright `require`.