Hi
I'm trying to create a ludwig.json file for Geofield module

the module contains a composer.json file and it contains:

{
  "name": "drupal/geofield",
  "description": "Stores geographic and location data (points, lines, and polygons).",
  "type": "drupal-module",
  "homepage": "https://www.drupal.org/project/geofield",
  "authors": [
    {
      "name": "Brandon Morrison",
      "homepage": "https://www.drupal.org/u/brandonian",
      "role": "Maintainer"
    },
    {
      "name": "Pablo López",
      "homepage": "https://www.drupal.org/u/plopesc",
      "role": "Maintainer"
    },
    {
      "name": "Italo Mairo",
      "homepage": "https://www.drupal.org/u/itamair",
      "role": "Maintainer"
    }
  ],
  "support": {
    "issues": "https://www.drupal.org/project/issues/geofield",
    "irc": "irc://irc.freenode.org/drupal-contribute",
    "source": "https://git.drupalcode.org/project/geofield"
  },
  "license": "GPL-2.0+",
  "minimum-stability": "dev",
  "require": {
    "phayes/geophp": "^1.2"
  }
}

so I create a ludwig.json file which is:

{
  "require": {
    "phayes/geophp": {
      "version" : "1.2",
      "url": "https://github.com/phayes/geoPHP/archive/1.2.zip"
    }
  }
}

but after downloading and extracting the zip file in

modules/geofield/lib/phayes-geophp/1.2

folder, the ludwig still says that the library is missing and the geofield module not working.

Am I doing this right? Is there some step I am missing?

Comments

Lleyton created an issue. See original summary.

avpaderno’s picture

Issue tags: -geofiled, -ludwig, -Composer
devad’s picture

Title: Create ludwig.json file for Geofield » Geofield - Add Ludwig integration
Project: Ludwig » Geofield
Status: Active » Needs review
StatusFileSize
new649 bytes

Hi @Lleyton and maintainers of Geofield module.

I am Ludwig module co-maintainer.

I would like to support idea that we add Ludwig integration into Geofield module by providing ludwig.json file inside your module's root folder in all future Geofield module releases.

This would make the life of users not friendly with Composer much easier. :)

phayes/geophp library has file which needs to be loaded manually.

Plus ludwig.json file of course.

{
  "require": {
    "phayes/geophp": {
      "version": "v1.2",
      "url": "https://github.com/phayes/geoPHP/archive/1.2.zip",
      "autoload_file": "geoPHP.inc"
    }
  }
}

Maintenance would not be a big issue in this case. Once new Geofield module module release is out and if library dependencies has changed - ludwig.json file and geofield.module file should be updated to new library requirements by Geofield module module maintainers just like composer.json file is updated.

Here is the patch for current dev.

It's pity that Geofield module branch tests are not functional. I have posted another issue about that. :)

itamair’s picture

Status: Needs review » Postponed (maintainer needs more info)

So is it needed an amend/integration to the phayes/geophp library itself, isn't it?
according to this:

phayes/geophp library has file which needs to be loaded manually.

Plus ludwig.json file of course.

BUT phayes/geophp library (still very solid, the most solid geo library for php) looks not maintained/updated since long time (years)
so it is not possibile to think to integrate it with ludwig.json file ...

itamair’s picture

and what about all the other modules that rely and depend from Geofield module, such as Geofield Map, Leaflet, Geocoder ... would they need to be integrated with additional ludwig.json file too?
But is really there (still) people trying to skip composer workflow and dependency management with Drupal 8 & 9??

devad’s picture

Re: @Lleyton #2

After patch #3 is applied Geofield library will be marked as "Missing" still - inside Ludwig's Reports > Packages table.

However, the Geofield module will work nicely.

I have updated an issue for Ludwig to try to add better support for libraries with autoload files here:

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

devad’s picture

@itamair

The new Ludwig module documentation has been added to Drupal.org recently. Please take a look at guide below where you can find answers to the most of the questions you posted in last few comments:

Ludwig integration guide and FAQ for contrib modules developers and maintainers

devad’s picture

Status: Postponed (maintainer needs more info) » Needs review
Related issues: +#3195238: Geocoder - Add Ludwig Integration
StatusFileSize
new87.49 KB
new794 bytes

NEW LUDWIG SERVICE

As of ver. 8.x-1.5 Ludwig module has introduced the 'ludwig.require_once' service to be used by contrib modules who need Ludwig integration for their 'classmap' and 'files' library types.

The new service is making the integration of 'classmap' and 'files' library types much easier. Only the one-time integration in contrib module's .module file is needed now - without the need for regular updates of that file later. Only the ludwig.json file should be kept in sync with composer.json file... which means less job for such contrib module maintainers.

NEW LUDWIG ARGUMENT - The UX improvement

As of ver. 8.x-1.4 Ludwig module has introduced the new "disable_warnings" ludwig.json argument. It is not mandatory but it can be used and set to TRUE by contrib modules with 'classmap' and 'files' library types. When set to TRUE it will suppress the warnings for such libraries at Ludwig Reports > packages page (/admin/reports/packages). This is improving the UX of Ludwig module for contrib modules with such libraries.

A new patch is attached.

Note: The screenshot is from Geocoder module being used together with Geofield module. See the "Related issue" linked here.

devad’s picture

StatusFileSize
new807 bytes

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:

-  $ludwig_require_once->ludwigRequireOnce('phayes/geophp', 'geoPHP.inc');
+  $ludwig_require_once->requireOnce('phayes/geophp', 'geoPHP.inc', dirname(__FILE__));
marcom2021’s picture

I'm getting an error after saving a node with a geofield field.

Warning: call_user_func_array() expects parameter 1 to be a valid callback, class '\geoPHP' not found in Drupal\geofield\GeoPHP\GeoPHPWrapper->load() (line 21 [...]/modules/geofield/src/GeoPHP/GeoPHPWrapper.php)

I'm using Ludwig 8.x-1.6 with patch #9 and Geofield 8.x-1.18. phayes/geophp 1.2 is marked as installed.

devad’s picture

Hi @marcoh182

I can not reproduce the error.

My article with Geofield field is saved without any errors in clean D9 installation..

It might be some collide with other modules.

Also... are you using D8 or D9? And what PHP ver. do you have in your server?

Can you try to reproduce your error on clean D8/D9 installation and report back please.

devad’s picture

Status: Needs review » Active
itamair’s picture

Thanks @devad. I am not going too much through the way Drupal Ludwig works (as I confidently work with Composer) but would love to integrate Ludwig support into Geofield.
Just let me know when this issue last patch is REALLY RTBC and could be committed into the module ...
I won't really test and review it.

marcom2021’s picture

Hi devad,

I found the issue. The patch on my geofield.module file somehow got messed up, so the phayes/geophp library was never loaded.
It never crossed my mind to check that file and I was going through all my installed modules and settings for anything that could be conflicting with the geofield module.

Oh well, that's 4 hours of my life I'm never getting back lol.

itamair’s picture

So what? Is it working fine for you too @marcoh182 or not???

marcom2021’s picture

Yes :)

devad’s picture

Status: Active » Reviewed & tested by the community

Hi @itamair. Thanks for getting involved here again.

I have tried my best regarding testing, and I do believe patch #9 is solid one.

I suppose we can move it to RTBC as per #16. Thanks for reporting back @marcoh182.

It would be nice to add Ludwig integration to Geofield module officially.

For maintainers, it is much easier to maintain one ludwig.json file then to deal inside issue queue with all kinds of "how can I use this module without composer" questions.

I have moved to Composer quite some tome ago, but Ludwig was an important bridge-like module for me in the beginning of Drupal 8 adoption.

It has a surprisingly steady usage rate increase at project usage statistics, so, it is continuing to be an important bridge for others obviously.

itamair’s picture

  • itamair committed 4d9856b on 8.x-1.x authored by devad
    Issue #3119331 by devad: Geofield - Add Ludwig integration
    

  • itamair committed cec7879 on 8.x-1.x
    Documentation updated with Note on support of Ludwig module/project (...
itamair’s picture

Status: Reviewed & tested by the community » Fixed

Finally ... all this committed into dev and into a brand new 8.x-1.20 Geofield release, with Ludwig clearly mentioned in Readme.md documentation and drupal.org project front page.
Thanks @devad ... thanks all the other contributors and testers.
Closing this.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.