Wordpress plugin not finding Composer Autoloader

When I try to use Autoload in my Wordpress plugin I get an unexpected error: not finding Warning: require(/home/251650.cloudwaysapps.com/geytjjwugd/public_html/wp-content/plugins/gik25-microdata/vendor/composer/../phpunit/phpunit/src/Framework/Assert/Functions.php): failed to open stream: No such file or directory in /home/251650.cloudwaysapps.com/geytjjwugd/public_html/wp-content/plugins/gik25-microdata/vendor/composer/autoload_real.php on line 55 Fatal error: require(): Failed opening required '/home/251650.cloudwaysapps.com/geytjjwugd/public_html/wp-content/plugins/gik25-microdata/vendor/composer/../phpunit/phpunit/src/Framework/Assert/Functions.php' (include_path='.:/usr/share/php') in /home/251650.cloudwaysapps.com/geytjjwugd/public_html/wp-content/plugins/gik25-microdata/vendor/composer/autoload_real.php on line 55 I've uploaded the files via SFTP Called require_once("vendor/autoload.php"); in the plugin entry file (it works) *The autoload.php file contains require_once DIR . '/composer/autoload_real.php';
Category: Web

composer not working on my plugin when i upload it to my website

im working in a plugin in localhost, it works fine in my localhost website im using composer in it but then when i upload it to my website then it trows a fatal error because composer autoload is not working, in the php file with the same name as my plugin i require the vendor autoload, the errors says that the files that i call wiht autoload do not exists i dont know to much about php or composer, i …
Category: Web

How to prevent Composer dependency conflicts amongst WP plugins?

In our plugin development we use Composer to install e.g. Symfony\Process that we later use in the code. The big question is how do we make sure that this dependency is not in a conflict with some other plugin also using Symfony\Process in another version. Now I know this is mostly an inherent PHP issue but still, we'd like to offer our users a solution that at least warns them when such conflict happens (instead of failing hard). One approach, …
Category: Web

Include Carbon Fields via Composer with Mozart

Coen Jacobs' Mozart is a tool to prevent namespace conflicts in Wordpress themes/plugins which utilize Composer for dependency management. It's similar to PHP Scoper but is described as simpler and Wordpress-oriented. I have mozart configured as follows: "extra": { "mozart": { "dep_namespace": "MZoo\\MyPlugin\\Dependencies\\", "dep_directory": "/src/Dependencies/", "classmap_directory": "/src/Classes/", "classmap_prefix": "MYPREFIX_", "packages": [ "htmlburger/carbon-fields" ], "delete_vendor_directories": true } }, All of the Carbon Fields files are namespace-prefixed and migrated to src/Dependencies/Carbon_Fields except the vendor/htmlburger/carbon-fields/config.php file, which resides above the core directory with …
Category: Web

Wordpress composer issues

I'm using composer to install wordpress but I have a situation when I run composer install I end up with a nested wp-content directory as follows. (Wordpress is the root install directory) wordpress/wp-content/wp-content All the default core Wordpress themes and plugins end up in the following directories. wordpress/wp-content/wp-content/themes wordpress/wp-content/wp-content/plugins All my plugins in the composer file end up in the correct directories wordpress/wp-content/plugins wordpress/wp-content/themes { "require": { "johnpbloch/wordpress": ">=5.4", "wpackagist-plugin/admin-menu-editor": "1.9.8", "wpackagist-plugin/autoptimize": "2.8.1", "wp-api/basic-auth": "dev-master", "wpackagist-plugin/blog2social": "6.6.0", "wpackagist-plugin/bulk-delete": "6.0.1", "wpackagist-plugin/contact-form-7": …
Category: Web

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')) { …
Category: Web

Wordpress Bedrock breaking plugin links

I recently switched to using WP-Bedrock and I currently like the workflow but there's a huge drawback for me. There are 2 URLs which previously were identical, due to Bedrock's file structure, are different. Site_URL: /wp Home_URL: A huge bunch of plugins are written taking in mind only regular WP installations. A very critical plugin for my site is currently unusable because the links to internal images look like this: https://<domain>/wp/https://<domain>/app/uploads/... I've tried to dig in the plugin files but …
Category: Web

Use Composer Package inside class - Namespacing error

I have my theme, with a folder called classes, with a single class: wp-content |- themes |- mycustomtheme |- classes |- FooBar.php In FooBar, I would like to use this package here: Soundasleep / HTML2Text. And use it like this: In FooBar.php doSomethingBadass( $some_html ){ wp_mail( '[email protected]', 'test', \Soundasleep\Html2Text::convert( $some_html ) ); } But whatever I do, I keep getting this error: Fatal error: Uncaught Error: Class 'Soundasleep\Html2Text' not found in /app/public/wp-content/themes/mycustomtheme/classes/FooBar.php:60 My attempt I assume that it's something to …
Category: Web

How can I have case-sensitive theme directory names when installed with Composer?

I'm using SatisPress (https://github.com/cedaro/satispress) to expose some premium plugins and themes as composer packages, because I would like to use the roots/bedrock boilerplate. Now I have the following issue: The Divi theme (https://www.elegantthemes.com/gallery/divi/) uses a capital letter for the themes directory ("Divi" not "divi"). Now when I use composer require satispress/divi it downloads the package and installs it to the correct directory and the theme is showing and is usable. However the themes directory is now all lower case ("divi" …
Category: Web

How to handle theme activation errors?

I am trying to implement the hook for activating a theme, that will install composer dependencies upon activation. In trying to figure out how to handle whether or not the vendor directory exists, I was wondering how to display the dependency errors if they occur, and what I can show instead of just a broken site. Also is there a way to maybe rollback to last theme, and send a notification that the theme is not able to be installed …
Category: Web

Deploying WordPress with Composer

I have been looking into setting up WordPress and its plugins and themes using composer. I notice alot of the tutorials around have composer installing wordpress into its own sub directory for example /wp and the themes, plugins, must use plugins to a completely different directory like /content. Is there a reason why it doesn't use /wp/content for the plugins/themes/ect and make /wp the web root? I noticed composer seems to properly install everything this way, so it there something …
Category: Web

Plugin development and composer

I'm developing a plugin and I'm quite new in that, so I trying to find the best solution for how to integrate composer with my plugin. The problem is that the SDK which I need is quite big, and when I integrate it on the plugin, the plugin has more than 50mb which is very big and some time on the plugin installation it's crashed because it is too big. I'm sending many data from the plugin on the Firebase …
Category: Web

How to update WP-CLI on Windows via Composer?

I installed wp-cli back in April on my Windows box using composer. I believe with the following command: composer create-project wp-cli/wp-cli --no-dev as outlined in the alternate install methods on here. I have since used "composer update --no-dev" to update but just realized that it is only updating the dependencies and not the wp-cli package itself. If I run a "wp cli version" it reports version WP-CLI 0.18.0, yet v0.20.4 is the latest released version. I can't seem to find …
Category: Web

local wordpress multisite not working on AWS development server "error establishing database connection"

I have a composer WP starter installation on my local mac using mamp. It works as expected. I'm using phpdotenv to hide my wp-config.php settings and I have the wordpress directory moved into a sub-directory under document root. I use a virtual host on the local mac dev2.domainname.com. I used wp db migrate pro to find and replace dev2 to dev3 as the domainname.com is the same on local and AWS. The only other difference is the database connection settings. …
Category: Web

Install wordpress using composer in a specific language

I'm using composer to automatically deploy wordpress on a ubuntu-server. Additionally, I need to install the german language pack. I learned that there are some guys who create composer-packages from the wordpress.org files. Using the following composer.json I get wordpress with german language pack: { "repositories": [{ "type": "composer", "url": "https://wp-languages.github.io" }], "require": { "johnpbloch/wordpress": "4.6", "koodimonni-language/core-de_de": "*" }, "extra": { "wordpress-install-dir": "wp", "dropin-paths": { "wp/wp-content/languages": ["vendor:koodimonni-language"], "wp/wp-content/languages/plugins/": ["vendor:koodimonni-plugin-language"], "wp/wp-content/languages/themes/": ["vendor:koodimonni-theme-language"] } } } The problem is, that wordpress itself …
Category: Web

Composer fails to download PHP Codesniffer to plugin

I am getting an error when trying to install the squizlabs/php_codesniffer package via composer into my WordPress plugin. I am using Flywheel for the local server, with composer 1.8.6 installed globally at /usr/local/bin/composer.phar I have also tried using the composer file locally in the plugin folder, but I still get the same error. This is the command I run while in the plugin directory composer require --dev squizlabs/php_codesniffer
Category: Web

How to provide a plugin which requires CMB2 (plugin dependencies)?

Every serious plugin developer probably has to deal with this problem: WordPress is not supporting composer or any dependency management by default. I have written a great plugin which I would like to put into the official repository on WordPress.org. Problem is: I do not want to write all of those options pages (including network options pages) on my own - this is why I am using the CMB2 library. It is actually a well known framework used by a …
Category: Web

How to properly use composer packages in wordpress?

I need to implement in a wordpress instance a feature that allows me to search for the most recent file with extension .xlsx in the wp-content/upload directory, once the file has been identified, it should be interpreted and finally insert the excel data in the wp_posts and wp_postmeta tables Following a certain logic. The packages of interest are symfony/finder phpoffice/phpspreadsheet What is the correct way to integrate and use packages within wordpress? I am new to worpress and I do …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.