How can I search all plugins for composer's vendor/autoload.php?
I've got projects (both themes and plugins) set up as composer projects. These projects can be dev-dependencies of each other. Right now I'm working on a theme which requires the vendor/autoload.php
file. However, when I bring that theme into another project (like a plugin), I still need access to the autoload.php
. The problem is that the autoload.php
file is now inside the directory structure for the plugin and not the theme.
define('FL_CHILD_THEME_DIR', get_stylesheet_directory());
define('FL_CHILD_THEME_URL', get_stylesheet_directory_uri());
if (!file_exists(FL_CHILD_THEME_DIR . '/vendor/autoload.php')) {
// somehow check all the directories within the plugins directory
// for vendor/autoload.php
} else {
require FL_CHILD_THEME_DIR . '/vendor/autoload.php';
}
}
I've tried using things like scandir
and glob
but I'm not getting any closer. I thought something like this would work, but I'm still no closer.
foreach(glob(plugin_dir_path() . 'vendor/autoload.php') as $file {
require $file;
}
Topic composer php plugin-development theme-development Wordpress
Category Web