Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [autoloading]

automatic loading of PHP classes without explicit include calls.

-2
votes
1answer
54 views

TinyButStrong (and OpenTbs) library not working [closed]

Download the lib from the web, script outside of Drupal with two include_once() and it works perfectly well. But reading questions and answers here show me this is no longer an option in a Drupal 8 ...
0
votes
0answers
33 views

EFQ with huge data

I'm using EFQ to load nodes. However when the data is huge the page naturally breaks. Is there a way to lazy load the EFQ result or any idea how to optimize it? Noting that the client doesn't want ...
0
votes
1answer
91 views

Use elasticsearch in custom module

I'm trying to call the elasticsearch library inside of my controller, but it's not working. I just don't know how to call it from inside my code. I'm not exactly sure how to call an autoload inside of ...
1
vote
1answer
41 views

use PHP library in Custom Controller

I have a custom module and in its controller i am using 'namespace + classname' format to included QRCode library (which is in root/vendor/). I have used composer to install library Now I am trying ...
0
votes
0answers
45 views

How to replace vendor to httpd.private/vendor?

Normally the vendor dir is placed outside the webdir. The structure on my hostingprovider is: --httpd.www - core - modules - themes - ect ... --httpd.private - vendor How to fix this issue?...
0
votes
1answer
484 views

The vendor class doesn't autoload

I am trying to port the Infusionsoft module to Drupal 8 and I need to load the infusionsoft/php-sdk library. I have been racking my brain all day trying to figure this out, but I cannot get the class ...
0
votes
0answers
112 views

WSOD , Autoload.php, Composer, and Two /Vendor directories

I'm going to try to be as thorough as possible. I have an AcquiaCloud-hosted Drupal site with 3 environments, dev, staging, and production. My team uses Acquia DevDesktop to work on this site. The ...
0
votes
1answer
49 views

Using 3rd party libraries [closed]

I'm trying to load https://github.com/PHPOffice/PHPExcel in a custom module. I've successfully added the library dependency to the composer.json file and Composer correctly downloads it into the '...
2
votes
3answers
3k views

Load external php library in custom module

I’ve read a lot of topic on this but i can’t figure why it is not working for me. I’ve built a custom module. It is working fine since return $output; in my controller class is working : I can see in ...
1
vote
3answers
334 views

Class not dynamically loaded in custom module

I have a very simple Drupal 7 module in which I want to load a custom class. I'm not able to load the class and I get the following error when I enable the module: Fatal error: Class 'Drupal\...
1
vote
2answers
45 views

Use a 3rd part library when uninstalling a module

my module uses several third part PHP libraries, loaded by using the library module supported by the x_autoload (several third part libraries are based on composer, so this support directly pointing ...
1
vote
0answers
429 views

PHP-EWS library and autoload classes

I'm trying to use PHP-EWS library, to make a connection with Exchange. So I declared two libraries like this : function mymodule_libraries_info() { $libraries = array( 'php-ews-master' =&...
1
vote
1answer
143 views

hook_menu wildcard auto-loader for webform submission?

In hook_menu() array keys, you can specificy wildcard tokens to autoload certain objects, such as %node to get the node object. Is there a wildcard autoloader token for webform submissions? Some ...
1
vote
1answer
69 views

Autoload Mapping for modules

I'm trying to better understand how Drupal 8 autoloading for classes is automatically mapped to the src directory in modules. Basically, I'd like to know how the system knows to look in the modules/...
8
votes
1answer
2k views

Loading dependencies from the vendor directory in a module using composer

I am using composer for managing dependencies in my drupal module. I specified my dependency in the composer.json file placed in my module's root directory. After running the composer install comand ...
1
vote
2answers
2k views

After upgrading, the autoloader is not working

Recently, I updated from 8.1.8 to 8.1.10 (via composer update). In my local environment (running scotchbox, PHP 5.6.14), it runs fine. When deployed to the staging server (running CentOS 6.7, PHP 5.5....
1
vote
0answers
133 views

Updating composer autoloader after moving modules

I have been using composer to install all Drupal modules, when I realized that they had not been installing to modules/contrib. So, I added this into my composer file: "installer-paths": { "modules/...
4
votes
4answers
4k views

Adding a library to a module using composer

I'm working on a module which will require a library that is already in composer. I added a line to my module's composer.json file: "require": { "markrogoyski/math-php" : "dev-master" } I ran ...
1
vote
2answers
2k views

Views Infinite Scroll progress Indicator

I am using the Drupal 8 Views Infinite Scroll module on my website. I have a button at the bottom of my view that when clicked, loads more nodes into the view. How can I manipulate the view to show ...
3
votes
1answer
526 views

How can I fix, or troubleshoot, Fatal Error Class not found with XHProf Module [closed]

I'm seeing the following error when I enable xhprof in Drupal 8 either via Drush or via Composer. Class 'Drupal\xhprof\RequestMatcher\XHProfRequestMatcher' not found in /var/www/mysite/docroot/...
0
votes
0answers
232 views

Class not loading

For my module cloudinary_storage_db I have a cloudinary_storage_db.services.yml with the following: services: cloudinary_storage_db: class: Drupal\cloudinary_storage_db\CloudinaryStorageDb ...
0
votes
0answers
29 views

Autoloading a class [duplicate]

I'm attempting to create a class 'dataForm' that extends FormBase, and has some essential functionality that I want added to every form that I create. So all my modules will create forms that extend ...
3
votes
1answer
55 views

Why does core uses the lib directory instead of the src one, for its classes?

Drupal 8 now uses the PSR-4 specification for namespaces and auto-loading; module developers need to keep their PHP classes in their module's src directory. However, if you look in the core directory, ...
1
vote
0answers
21 views

Auto submit form with argument from URL [duplicate]

I have Drupal module with a form and it works just fine (/my_module/search) I need menu hook for my_module/search/% and to be auto submitted and repopulate the form with the argument form url. So ...
0
votes
1answer
61 views

Conditionally load PHP class

I made 2 custom modules: boutique and paypal. paypal is a dependance of boutique. I check if paypal is enabled, with the following code. namespace Drupal\boutique\Form\Multistep; use Drupal\Core\...
0
votes
1answer
226 views

xautoload not loading class

I have a PHP class that I have developed to mediate the interactions with a client's SSO web service. The class needs to be used by both a Symfony site and a Drupal 7 site. On the Drupal side, I've ...
1
vote
1answer
53 views

Class Autoloading include file

Class autoloading isn't working in custom module to extend webforms. Trying to call a function like this: $utility = new webform_kk_utility(); $utility->getComponents('aaa') getting this error: [...
-1
votes
1answer
154 views

load a class in hook_install

In my custom module I have created a class in mymod/src/Controller/TestClass.php. In hook_install I want to call a function of that class function mymod_install() { Drupal\mymod\TestClass::...
1
vote
0answers
431 views

Including an external library functioning using namespace with xautoload

I'm trying to include the PHPInsight library for performing sentiment analysis on user data. Based on the demo file provided in it, I added it into the sites/all/libraries path so that it would read ...
4
votes
1answer
108 views

Can composer-dependent PHP libraries be used with the Libraries API?

I'm trying to include a PHP library called Geocod.io in my custom module. I am also trying to use the Libraries API. So far I have: Downloaded geocod.io to sites/all/libraries composer install'ed in ...
7
votes
4answers
4k views

How to autoload classes from a 3rd party PHP library

I would like to use a 3rd party PHP library in my module and I wanted to ask what I need to do to autoload the classes? Example: Drupal\my_module\MyClass wants to instantiate ThirdPartyNamespace\...
2
votes
1answer
2k views

How do I load an external class into the Controller? [duplicate]

I'm playing with module building in Drupal 8, but can't really figure out how to include a custom class which does not extend any other. The class' only purpose is to reduce the amount of code I have ...
10
votes
2answers
8k views

How to include custom class file in Drupal 8 module

In Drupal 7 module development, I could include a custom inc, api, or php class file using the file[]= directive in the module.info file or the drupal_load_included() function. With D8 using PSR, ...
3
votes
1answer
1k views

How do I autoload a class with the X Autoload module?

I have X Autoload installed and enabled. I'm trying to get a simple example to work. The below setup throws the error: Fatal error: Class 'Pet' not found in MY-SITE/sites/all/modules/foo/foo....
1
vote
1answer
336 views

xautoload classes in subfolders

I have issues autoloading classes found in subfolders of my module with xautoload. my module is called myentity Here is my hook_entity_info function myentity_entity_info() { $return['myentity'] ...
4
votes
2answers
1k views

files[]=lib.php fails to autoload classes of different namespace?

In my custom module, I've included a file using files[]=foo.php in the .info file. foo.php declares classes in a namespace. Drupal does not seem to be autoloading this class: in my main module file $...
2
votes
1answer
449 views

Storing objects of custom type in $_SESSION - legal way?

I'm trying to figure out: can I load custom class (defined in module) to be loaded before session starts and its contents processed by PHP (unserialized) - is where any legal way to do this? (without ...
1
vote
2answers
217 views

Drupal + Simpletest + Class Autoloading = FALSE?

Just a quick question which I couldn't Google : is class autoloading not "enabled" when running tests using SimpleTest? I'm using the Drupal SimpleTest module, and I'm trying to instantiate a class ...
1
vote
0answers
92 views

Auto fill in content type

I have content type called services which has multiple filtered views. What I need to do is when a new user registers his information, than I insert into that content type (services) one or more ...
1
vote
3answers
124 views

Autoload files by patterns instead of listing each file

Drupal's "autoloading" requires one to include the files in files[] declarations in the .info file. When there are a lot of files, this becomes: A large, huge, list. Hard to maintain. Is there a ...