Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

How to use external libraries in a plugin

Started by Muut Archive 10 years ago · 1 replies · 531 views
10 years ago

This is probably a stupid question, but here it is anyway; I've added a library with composer to my plugin, but I don't know how to instantiate my class: none of these require statements work:

PHP
require_once(__DIR__ . '/vendor/autoload.php');
            //require_once (__DIR__ . '/vendor/campaignmonitor/createsend-php/csrest_subscribers.php');
            //$subscribers = require_once(__DIR__ . '/classes/createsend/csrest_subscribers.php');
            $LIST_id = $this->config->get('plugins.campaignmonitor.listid');
            $API_key = $this->config->get('plugins.campaignmonitor.apikey');
            $this->createsend = new CS_REST_Subscribers($LIST_id, $API_key);

I get: PHP Fatal error: Class 'Grav\Plugin\CS_REST_Subscribers' not found
So it's looking in the plugin namespace, instead of looking for the composer library.
How should I do this?

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1366 9 years ago
Archive · by Muut Archive, 9 years ago
2 940 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2960 9 years ago
Archive · by Muut Archive, 9 years ago
3 1125 9 years ago