• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
trying to require

#1
I am trying to use the sendpulse library.  First I tried to load it with Composer but composer complains that I should be using Composer2. When I try to upgrade to Composer2 that fails. So then I tried to manually load. 

I tried

require APPPATH."../vendor/sendpulse-rest-api-php-master/src/Storage/ApiInterface.php";

I am getting this error:
Severity: Warning
Message: require(/app/application/../vendor/sendpulse-rest-api-php-master/src/Storage/ApiInterface.php): failed to open stream: No such file or directory


then I tried:

require "/vendor/sendpulse-rest-api-php-master/src/Storage/ApiInterface.php";
but I get the following:
Message: require(/vendor/sendpulse-rest-api-php-master/src/Storage/ApiInterface.php): failed to open stream: No such file or directory

and then I tried:

require ("sendpulse-rest-api-php-master/src/Storage/ApiInterface.php");

But I get
Message: require(sendpulse-rest-api-php-master/src/Storage/ApiInterface.php): failed to open stream: No such file or directory

I then changed the owner with chown and the permissions with chmod. Now when I ls -l I get:

[email protected]:/opt/docker-substantiator2/app/vendor/sendpulse-rest-api-php-master/src$ ls -l ApiInterface.php

-rwxrwxrwx 1 richb201 richb201 10828 Dec 15 10:25 ApiInterface.php


But I still get:
A PHP Error was encountered

Severity: Compile Error

Message: require(): Failed opening required 'sendpulse-rest-api-php-master/src/Storage/ApiInterface.php' (include_path='.:/opt/bitnami/php/lib/php')
Filename: controllers/Users_start_login.php


Can anyone tell me what is wrong?
proof that an old dog can learn new tricks
Reply

#2
If it is not working then your paths are wrong.

Here is how to manually load it.

PHP Code:
// require("your-path/sendpulse-rest-api-php/src/ApiInterface.php");
// require("your-path/sendpulse-rest-api-php/src/ApiClient.php");
// require("your-path/sendpulse-rest-api-php/src/Storage/TokenStorageInterface.php");
// require("your-path/sendpulse-rest-api-php/src/Storage/FileStorage.php");
// require("your-path/sendpulse-rest-api-php/src/Storage/SessionStorage.php");
// require("your-path/sendpulse-rest-api-php/src/Storage/MemcachedStorage.php");
// require("your-path/sendpulse-rest-api-php/src/Storage/MemcacheStorage.php"); 

Then you will need to use the use clause in your controllers rtc;

You can find the rest on their GitHub page.

SendPulse REST client library

Read the README.md file.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
Yes, I am aware of their docs. What is wrong with my paths from a CI3 point of view? I have tried a number of different ways to describe the path. Right now it is:
require ("sendpulse-rest-api-php-master/src/Storage/ApiInterface.php");
require ("sendpulse-rest-api-php-master/src/Storage/ApiClient.php");
require ("sendpulse-rest-api-php-master/src/Storage/TokenStorageInterface.php");
require ("sendpulse-rest-api-php-master/src/Storage/FileStorage.php");
require ("sendpulse-rest-api-php-master/src/Storage/SessionStorage.php");
require ("sendpulse-rest-api-php-master/src/Storage/MemcachedStorage.php");
require ("sendpulse-rest-api-php-master/src/Storage/MemcacheStorage.php");
require ("sendpulse-rest-api-php-master/src/Storage/MemcacheStorage.php");
proof that an old dog can learn new tricks
Reply

#4
From CI 3 point of view namespaces.

Their namespace is:

namespace Sendpulse\RestApi;
namespace Sendpulse\RestApi\Storage;

You should use Composer to install it.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#5
(05-04-2021, 11:55 AM)InsiteFX Wrote: From CI 3 point of view namespaces.

Their namespace is:

namespace Sendpulse\RestApi;
namespace Sendpulse\RestApi\Storage;

You should use Composer to install it.
Yes, I tried. It complained that I was using Composer when I should be using Composer2. So I tried to upgrade Composer and I get an error:

[email protected]:/opt/docker-substantiator2/app/vendor/sendpulse-rest-api-php-master/src$ composer selfupdate
Updating to version 2.0.13 (stable channel).
  Downloading (100%)       

                                                                                                       
  [ErrorException]                                                                                     
  rename(/home/richb201/.cache/composer/composer-temp.phar,/usr/local/bin/composer): Permission denied

I managed to get Composer to upgrade. What dire do I need to run this from?
[email protected]:/opt/docker-substantiator2/app$ composer require sendpulse/rest-api
Using version ^1.0 for sendpulse/rest-api
./composer.json has been updated
Running composer update sendpulse/rest-api
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

Problem 1
- aws/aws-sdk-php is locked to version 3.145.1 and an update of this package was not requested.
- aws/aws-sdk-php 3.145.1 requires ext-simplexml * -> it is missing from your system. Install or enable PHP's simplexml extension.
Problem 2
- php-http/httplug-bundle is locked to version 1.18.0 and an update of this package was not requested.
- php-http/httplug-bundle 1.18.0 requires php ^7.2 -> your php version (5.6.40) does not satisfy that requirement.
Problem 3
- fusionauth/fusionauth-client is locked to version 1.19.0 and an update of this package was not requested.
- fusionauth/fusionauth-client 1.19.0 requires ext-curl * -> it is missing from your system. Install or enable PHP's curl extension.

To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/5.6/cli/php.ini
- /etc/php/5.6/cli/conf.d/10-mysqlnd.ini
- /etc/php/5.6/cli/conf.d/10-opcache.ini
- /etc/php/5.6/cli/conf.d/10-pdo.ini
- /etc/php/5.6/cli/conf.d/20-calendar.ini
- /etc/php/5.6/cli/conf.d/20-ctype.ini
- /etc/php/5.6/cli/conf.d/20-exif.ini
- /etc/php/5.6/cli/conf.d/20-fileinfo.ini
- /etc/php/5.6/cli/conf.d/20-ftp.ini
- /etc/php/5.6/cli/conf.d/20-gettext.ini
- /etc/php/5.6/cli/conf.d/20-iconv.ini
- /etc/php/5.6/cli/conf.d/20-json.ini
- /etc/php/5.6/cli/conf.d/20-mbstring.ini
- /etc/php/5.6/cli/conf.d/20-mcrypt.ini
- /etc/php/5.6/cli/conf.d/20-mysql.ini
- /etc/php/5.6/cli/conf.d/20-mysqli.ini
- /etc/php/5.6/cli/conf.d/20-pdo_mysql.ini
- /etc/php/5.6/cli/conf.d/20-phar.ini
- /etc/php/5.6/cli/conf.d/20-posix.ini
- /etc/php/5.6/cli/conf.d/20-readline.ini
- /etc/php/5.6/cli/conf.d/20-shmop.ini
- /etc/php/5.6/cli/conf.d/20-sockets.ini
- /etc/php/5.6/cli/conf.d/20-sysvmsg.ini
- /etc/php/5.6/cli/conf.d/20-sysvsem.ini
- /etc/php/5.6/cli/conf.d/20-sysvshm.ini
- /etc/php/5.6/cli/conf.d/20-tokenizer.ini
- /etc/php/5.6/cli/conf.d/20-xdebug.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.
proof that an old dog can learn new tricks
Reply

#6
I was told by sendPulse to run it in the vendor dir where I put sendPulse.

so I ran this:

[email protected]:/opt/docker-substantiator2/app/vendor/sendpulse-rest-api-php-master$ composer require sendpulse/rest-api
Using version ^1.0 for sendpulse/rest-api
Root package 'sendpulse/rest-api' cannot require itself in its composer.json

What does this mean? Is there something wrong in sendPulse's composer.json?
proof that an old dog can learn new tricks
Reply

#7
I have added it this way:

require "vendor\sendpulse-rest-api-php-master\src\ApiClient.php";
require "vendor\sendpulse-rest-api-php-master\src\Storage\FileStorage.php";


But I get the error:
A PHP Error was encountered

Severity: Compile Error
Message: require(): Failed opening required 'vendor\sendpulse-rest-api-php-master\src\ApiClient.php' (include_path='.:/opt/bitnami/php/lib/php')
Filename: controllers/Users_start_login.php

Does my path need anything else?
proof that an old dog can learn new tricks
Reply

#8
Getting closer..
Turns out that in the file ApiClient.php they have this code at the top:
namespace Sendpulse\RestApi;

use Exception;
use Sendpulse\RestApi\Storage\FileStorage;
use Sendpulse\RestApi\Storage\TokenStorageInterface;
use stdClass;

I noticed that these paths are not the same ones that Composer installed. So clearly I will need to change these paths. But before I do I want to make sure that namespace, Exception, stdClass are not over riding what seems like an obvious fix. anyone know how this works?
proof that an old dog can learn new tricks
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.