Hi, is it possible to get this to install using the ludwig module cos I have trouble using composer on my shared hosting.

I've tried, but this is stretching me...

I've created a file called ludwig.json with the following code in:

{
    "require": {
        
        "swiftmailer/swiftmailer": {
            "version": "v5.4.8",
            "url": "https://github.com/swiftmailer/swiftmailer/archive/v5.4.8.zip"
        }
    }
}

this makes ludwig list:
swiftmailer/swiftmailer
Download the library and place it in modules/swiftmailer/lib/swiftmailer-swiftmailer/v5.4.8
v5.4.8 swiftmailer Missing

but when I try unzipping the file in the folder modules/swiftmailer/lib/swiftmailer-swiftmailer/v5.4.8 it doesn't change from missing. I also tried executing the drush command "drush ludwig-download" but that didn't help either. The files are definitely there in that folder.

maybe I'm missing something...

I also tried putting the files in sites/all/libraries/vendor/swiftmailer/swiftmailer and /vendor/swiftmailer/swiftmailer incase.. but that didn't work either.

ho hum.

composer is tricky when you're using shared hosting.

Comments

benjarlett created an issue. See original summary.

devad’s picture

I have tried the same as described in #0 and the result is the same.

It would be great if we can make this module to work with ludwig.

Any idea why ludwig fails with swiftmailer library?

devad’s picture

webflo’s picture

Status: Active » Postponed

I looked through the ludwig code base a bit. I think it handles only psr-0, psr-4 style autoloading. But Swift Mailer uses some custom code via "audoload.file".

cybertrail’s picture

All the document suggest using Swiftmailer, installed with Composer, but I only have shell access on a few of my customers sites. I can use Composer on these but was glad to find Ludwig for the others. The recommendation to switch to a hosting service that provides shell access is fine but working on many servers, each with their own setup makes, that suggestion impossible. Is there anyway to get Ludwig working for Switfmailer? Luckily Webform PHP Mailer seems to do the job until then.

devad’s picture

Status: Postponed » Closed (won't fix)
Related issues: +#3040695: Entity Print - Add Ludwig integration

After digging a bit deeper into Swiftmailer module composer.json file and composer installation it came to the surface that libraries listed inside module's composer.json file are not the only ones which have to be included into ludwig.json file.

Some other libraries are required by them either directly or indirectly (by their child libraries).

Here is the full list of (currently) required libraries for Swiftmailer module installation from composer report:

- Installing symfony/css-selector (v5.1.6): Downloading (100%)
- Installing tijsverkoyen/css-to-inline-styles (2.2.3): Downloading (connectinDownloading (100%)
- Installing swiftmailer/swiftmailer (v6.2.3): Downloading (100%)
- Installing html2text/html2text (4.3.1): Downloading (100%)

So, all these libraries should be added to ludwig.json file in order for Swiftmailer module to work nicely in full capacity.

Additionally, a few lines of code should be added to .module and .install files as manual integration for swiftmailer library.

Update: See and test patch #11.

devad’s picture

Title: installation using ludwig possible? » Swift Mailer - Ludwig integration abandoned
devad’s picture

Title: Swift Mailer - Ludwig integration abandoned » Swift Mailer - Ludwig integration given up
devad’s picture

devad’s picture

devad’s picture

Title: Swift Mailer - Ludwig integration given up » Swift Mailer - Add Ludwig integration
Status: Closed (won't fix) » Needs review
StatusFileSize
new1.94 KB

Here is the patch which is enough to add Ludwig integration into Swiftmailer module.

Ludwig does not have full support for 'files' autoload type libraries yet. But I have tested, and with adding few lines of code into into swiftmailer.module file and into swiftmailer.install file the integration works well.

I have edited my previous comment #6 accordingly.

It would be nice to help all Drupal users who are not familiar with Composer yet and give them an alternative... but let's see what the maintainers of Swiftmailer module will decide about adding Ludwig integration to Swiftmailer module officially.

Maintenance of this integration should be relatively easy. When the new versions of libraries are required the ludwig.json file should be updated, and if the new version of swiftmailer library is required then the update of swiftmailer.module file and swiftmailer.install file is needed as well. It takes 10-15 min only to synchronize all these files with new composer.json file every few months when new library requirements are needed, so it should not be a lot of work for module maintainers.

Update note: The D9.1 tests failed because of the branch fail.

devad’s picture

StatusFileSize
new2.01 KB

The new "disable_warnings": "TRUE" ludwig.json option is added to just released Ludwig 8.x-1.2.

Swiftmailer can use it nicely to disable "Classmap" warning for manually implemented integration.

devad’s picture

StatusFileSize
new721 bytes

Interdiff.

devad’s picture

StatusFileSize
new2.95 KB

Ignore this one. Test patch #17.

devad’s picture

StatusFileSize
new2.34 KB

Interdiff.

devad’s picture

StatusFileSize
new3 KB

Moving "if Ludwig module exists" part of code to the Helper function for simplicity reasons.

devad’s picture

StatusFileSize
new2.61 KB

Moving the Ludwig Helper function 'ludwig_require_once' to new ludwig.inc file so that any script (.module, .install) can require it once.

When library requirements are upgraded (in some future release), the only file which needs sync with new library versions now is the ludwig.json file. This makes job for Swiftmailer module maintenaires easy.

BTW... congratulations for #2223967: Do not decode a contact message twice.

A note for Swiftmailer module maintainers

My vote is to add official Ludwig integration to Swiftmailer module before stabile Swiftmailer 2.0 release. So that all Drupal 8/9 users who are not familiar with Composer can use Swiftmailer module still (with Ludwig).

Ludwig module has nice and very detailed documentation added to Drupal.org recently.

Ludwig is improved a lot in last 2 months, including stabile D9 release.

It has 6700+ users currently and very steady Weekly usage increase despite opinions that "Everybody is using Composer nowadays". :)

devad’s picture

It seems that Swiftmailer module branch tests have some issues with latest Drupal Core .dev releases which need a fix: #3182622: Fix 2.x branch tests

devad’s picture

With #3182622: Fix 2.x branch tests fixed, tests here are working well also.

Patch #17 is ready for further reviews.

rroose’s picture

Hi devad,

Thanks for all the work so far. All the libraries work except for the Swiftmailer library:

/contrib/swiftmailer/lib/swiftmailer-swiftmailer/v6.2.3

Ludwig keeps saying it's still missing even though it's placed in the right directory. Any idea why that one is not working?

devad’s picture

Re: @rroose

Please, update your Ludwig module to latest 8.x-1.4 version if you didn't do so already.

Swiftmailer 8.x-2.x-dev + Patch #17 in combination with Ludwig 8.x-1.4 should not give you any 'missing' libraries messages.

Please, try and post back your result.

rroose’s picture

@devad

That fixed the issue, many thanks.

devad’s picture

Status: Needs review » Reviewed & tested by the community

Welcome. Thank you for reporting back @rrose. Marking RTBC as per comment #22.

devad’s picture

Version: 8.x-1.0-beta1 » 8.x-2.x-dev
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.98 KB

In Ludwig ver. 8.x-1.5 a new Ludwig service is added which can be used instead of ludwig.inc file here.

The 'files' and 'classmap' libraries integration with Ludwig are more simple now.

New patch attached.

devad’s picture

Patch #24 is a new approach using new ludwig.require_once service. So, no need for interdiff.

Libraries are updated to latest versions as well.

CPxiom’s picture

This works, swift mailer was installed without problems. Using Drupal 9 with php .
Thank you for this integration patch.
I really wonder why ludwig is not a standard for drupal modules. It feels native to drupal.
Or maybe on Ludwig side, it would be nice to be able to read what is needed, maybe from composer.json? I'm not a coder btw.
Thank you for this.

CPxiom’s picture

Status: Needs review » Reviewed & tested by the community
devad’s picture

Thanx for review and RTBC report @CPxiom. Appreciated.

Ludwig has its limitations. So, I do not see it being ever added to core.

However, with all its limitations it can still help a lot if some Drupal users are not familiar with Composer yet.

Read more about Ludwig limitations in the FAQ section of this guide. The target of this FAQ section are contrib module developers... so it is a bit technical talk. :)

devad’s picture

StatusFileSize
new2 KB

Patch reroll for new Ludwig 8.x-1.6 (due to slight service API change).

#2914840-20: Add support for 'classmap' and 'files' autoload types

One line interdiff in both .module and .install files:

-  $ludwig_require_once->ludwigRequireOnce('swiftmailer/swiftmailer', 'lib/swift_required.php');
+  $ludwig_require_once->requireOnce('swiftmailer/swiftmailer', 'lib/swift_required.php', dirname(__FILE__));
joshuautley’s picture

#29 worked perfectly for me. Thank you!

devad’s picture

Thanks for review. RTBC confirmed as per #30.