Composer removes packages & causes PHPMailer Error when developing custom extension Topic is solved

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
mb87
Joomla! Apprentice
Joomla! Apprentice
Posts: 40
Joined: Wed Jan 20, 2010 4:37 pm

Composer removes packages & causes PHPMailer Error when developing custom extension

Post by mb87 » Mon Aug 02, 2021 12:58 am

I'm building a custom extension that requires several external libraries. Therefore I needed to use Composer to install them. However, when I do that, Composer immediately removes a long list of Joomla packages, which breaks the site.

I've been able to fix the problem by manually adding the libraries back in Composer. This works for everything EXCEPT PHPMailer. I can't seem to find a way to make it found, even though I have added it back through Composer and the files exist.

Suggestions on how to fix this?

For reference, I'm running the following setup:

Joomla 3.9.28
PHP 7.4.21

Here are the steps I followed:

1. This is the result when I added the library I needed for my component (docraptor/docraptor) as required in Composer.

Code: Select all

Lock file operations: 9 installs, 0 updates, 0 removals
  - Locking docraptor/docraptor (2.0.0)
  - Locking guzzlehttp/guzzle (6.5.5)
  - Locking guzzlehttp/promises (1.4.1)
  - Locking guzzlehttp/psr7 (1.8.2)
  - Locking psr/http-message (1.0.1)
  - Locking ralouphie/getallheaders (3.0.3)
  - Locking symfony/polyfill-intl-idn (v1.23.0)
  - Locking symfony/polyfill-intl-normalizer (v1.23.0)
  - Locking symfony/polyfill-php72 (v1.23.0)


Package operations: 0 installs, 0 updates, 40 removals
  - Removing symfony/yaml (v5.3.6)
  - Removing symfony/polyfill-php55 (v1.20.0)
  - Removing symfony/polyfill-mbstring (v1.23.1)
  - Removing symfony/polyfill-ctype (v1.23.0)
  - Removing symfony/deprecation-contracts (v2.4.0)
  - Removing simplepie/simplepie (1.5.6)
  - Removing psr/simple-cache (1.0.1)
  - Removing psr/log (1.1.4)
  - Removing psr/http-factory (1.0.1)
  - Removing psr/http-client (1.0.1)
  - Removing psr/container (1.1.1)
  - Removing phpseclib/phpseclib (3.0.9)
  - Removing phpoffice/phpspreadsheet (1.18.0)
  - Removing phpmailer/phpmailer (v6.5.0)
  - Removing paragonie/random_compat (v2.0.20)
  - Removing paragonie/constant_time_encoding (v2.4.0)
  - Removing myclabs/php-enum (1.8.3)
  - Removing markbaker/matrix (2.1.3)
  - Removing markbaker/complex (2.0.3)
  - Removing maennchen/zipstream-php (2.1.0)
  - Removing leafo/lessphp (v0.5.0)
  - Removing joomla/utilities (1.6.2)
  - Removing joomla/uri (1.2.0)
  - Removing joomla/string (1.4.5)
  - Removing joomla/session (1.6.0)
  - Removing joomla/registry (1.6.3)
  - Removing joomla/input (1.4.0)
  - Removing joomla/image (1.5.1)
  - Removing joomla/filter (1.4.3)
  - Removing joomla/filesystem (1.6.0)
  - Removing joomla/event (1.3.0)
  - Removing joomla/di (1.5.1)
  - Removing joomla/data (1.2.0)
  - Removing joomla/compat (1.2.0)
  - Removing joomla/archive (1.1.10)
  - Removing joomla/application (1.9.2)
  - Removing ircmaxell/password-compat (v1.0.4)
  - Removing google/recaptcha (1.2.4)
  - Removing ezyang/htmlpurifier (v4.13.0)
  - Removing components/font-awesome (5.15.3)
2. After adding back the missing packages, here's my composer.json file. Note that I added phpmailer to both the "require" and "autoload" sections. However, it doesn't seem to matter if I add or remove them from both. I get the same result.
composer-json.png
3. This is the error I receive (with debugging enabled) when logging in to the administrator page. I should be receiving an email from Akeeba Admin Tools indicating that an administrator has logged in. I believe that is what is triggering the error, however, no other email functions work in my portal either.
PHPMailerError.png
4. Here you can see the files that are allegedly missing. They are not missing, they are where they are expected to be.
MailFiles.png
Any thoughts and suggestions you can share will be created appreciated!
You do not have the required permissions to view the files attached to this post.
Last edited by toivo on Mon Aug 02, 2021 7:16 am, edited 1 time in total.
Reason: mod note: moved from 3.x General Questions, retitled

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2886
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Composer Causes PHPMailer Error

Post by SharkyKZ » Mon Aug 02, 2021 7:12 am

Do not use Composer in Joomla's root directory. Keep your extension's dependencies in your extension's directory.

mb87
Joomla! Apprentice
Joomla! Apprentice
Posts: 40
Joined: Wed Jan 20, 2010 4:37 pm

Re: Composer removes packages & causes PHPMailer Error when developing custom extension

Post by mb87 » Mon Aug 02, 2021 2:37 pm

Thanks @SharkyKZ. To clarify, are stating that I should not create or update the composer.json file in the /var/www/html/libraries directory?

If so, then instead I should run composer from the directory where the library is located? In this case, the library I need (docraptor) is located in a directory such as /var/www/html/libraries, but the composer.json file is created and located in something like:

/var/www/html/components/com_myextenstion

Am I understanding correctly?

I wasn't clear previously, but currently, I have composer.json and composer.lock in the /var/www/html/libraries directory.

Thanks again.

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2886
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Composer removes packages & causes PHPMailer Error when developing custom extension

Post by SharkyKZ » Mon Aug 02, 2021 6:12 pm

Yes, keep your extension's dependencies separate from Joomla's dependencies. Create your own composer.json, install libraries in your extension's vendor directory and manually load your autoload.php file.


Locked

Return to “Joomla! 3.x Coding”