Welcome Guest, Not a member yet? Register   Sign In
Using a third party class in CI4
#1
Question 
(This post was last modified: 06-15-2022, 09:26 PM by Sincere.)

I want to use the influxdb-php class in CI4:
https://github.com/influxdata/influxdb-php
I tried calling the class from the controller using:

PHP Code:
use InfluxDB;
use 
InfluxDB\Client;
use \
InfluxDB;
use \
InfluxDB\Client

But no success. I installed it using composer:
Code:
composer require influxdb/influxdb-php
Reply
#2

use InfluxDB\Client;

new Client(.....);
Reply
#3

I'm still getting the following error:
Code:
Class "InfluxDB\Client" not found

When using:
PHP Code:
use InfluxDB\Client;
// and
new Client('localhost',8086); 
Reply
#4

CI 4.2.0 installed via composer (updated to 4.2.1)
influxdb/influxdb-php - installed via composer.
Works.

Have you done any manipulations with the structure of the application?
Reply
#5

None that I'm aware of. What should I look out for? Where can I look?
Reply
#6

By default, the vendor directory (where the composer stores the autoloader and packages) is in the root directory.
If you have changed the directory structure, you must ensure that the COMPOSER_PATH constant (app/Config/Constants.php) points to the correct path for the composer autoloader.
Reply
#7

It appears to be fine:
defined('COMPOSER_PATH') || define('COMPOSER_PATH', ROOTPATH . 'vendor/autoload.php');

I have myth-auth installed and operational as well through composer. So I don't understand why specifically the InfluxDB client won't load.
Reply
#8

"Solved" is by re-creating a new CI4 install, installing the required packages using composer, and copying over the controllers, models, views etc. from the original install. It works now... Huh
Reply




Theme © iAndrew 2016 - Forum software by © MyBB