0

I am using the 3d party php library, and I do not know how to connect. The file structure of my project looks like following:

-my_project
--src
---Plugin
----Action
-----MyAction.php
---libs
----mylibs
-----src
------ClassWhichINeed.php

--my_project.info.yml

So I need to connect ClassWhichINeed.php to MyAction.php. In ClassWhichINeed.php I specified namespace as Drupal\my_project\mylibs;

And in MyAction.php i use Drupal\my_project\mylibs;

But when I create $object = new ClassWhichINeed;

I get an error "Undefiened class"

1
  • 1
    Use Composer to pull in external dependencies to the project. The autoloader will know how to find them when you add them with use ... statements.
    – Kevin
    Commented Nov 14, 2018 at 15:08

1 Answer 1

-1

suggestion:

in MyAction.php add:

require_once DRUPAL_ROOT . '/modules/my_project/src/libs/mylibs/src/ClassWhichINeed.php';
1
  • 1
    This is not necessary to be doing this in Drupal 8.
    – Kevin
    Commented Nov 14, 2018 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.