Turning custom code into an extra

Hi there, I recently build a component that allow a seamless integration betwen Vue and modX, but now im looking into making it an extra, I’m already looking at this two resources

I already have my POC working but in the following structure:

What confuses me is what should be the next step? first should I reorganize controllers and assets into core and other folders as directed on the extra tutorial and make sure it keeps working, then use the GMP packager, or go straigth to package then start fixing issues?

You could have a build script place all that in assets and call it a day, but it would definitely be considered best practice to break up what needs to be publicly accessible (assets, scripts etc) and what should be locked down (core; controllers, internal files, any PHP files except public endpoints).

I personally prefer plain build scripts over GPM or other packagers to have more control, but for basic packaging needs they all work fine.

1 Like

Thanks a lot, I went the reorganization path and now my folders looks like this

image

Today I’ll be digging into actually building the package and adding the snippets/chuncks that I have, yet I still have a doubt, I have some rest webservices, currently it’s just a php file that validates a key using JWT and a ,htaccess file, all this in a custom folder inside html, is this the rigth way? or should it be a snippet called inside a standard modx resource?

There is a also MyConponent.

1 Like

Thanks a lot bob, finally seems like I’m in the final fixes, hope to be able to share the extra soon

Im just kind of hit anotther issue that has my head scratching, for some reason, all the elements, but my resource get created, and im not seeing any log in modx or apache, what could I be missing?

{
  "name": "Kraken",
  "lowCaseName": "kraken",
  "description": "Simple integration to easily use VueJs inside modx",
  "author": "@camicase82",
  "version": "0.0.1",
  "package": {
    "actions": [{
      "id": 1,
      "controller": "init",
      "hasLayout": 1,
      "langTopics": "package:default",
      "assets": ""
    }],
    "menus": [{
      "text": "Kraken blocks",
      "description": "El packete de juanito",
      "action": "init",
      "parent": "components",
      "icon": "",
      "menuIndex": 0,
      "params": "",
      "handler": ""
    }],
    "elements": {
      "plugins": [
        {
          "name": "krakenBlocksTab",
          "file": "krakenBlocksTab.php",
          "events": [
            "OnDocFormPrerender"
          ]
        }
      ],
      "snippets": [
        {
          "name": "generateVueComponentsFiles",
          "file": "generateVueComponentsFiles.php"
        },
        {
          "name": "krakenBlockRenderer",
          "file": "krakenBlockRenderer.php"
        },
        {
          "name": "krakenBlocks",
          "file": "krakenBlocks.php"
        },
        {
          "name": "vueImportRenderer",
          "file": "vueImportRenderer.php"
        }
      ],
      "chunks": [
        {
          "name": "head",
          "file": "head.html"
        }
      ],
      "templates": [
        {
          "name": "krakenTemplate",
          "file": "krakenTemplate.html"
        }
      ],
      "resources": [{
        "pagetitle": "singlecomponetrenderer",
        "file": "singlecomponetrenderer.html",
        "published ": 1,
        "alias": "singlecomponetrenderer",
        "template": "krakenTemplate"
      }]
    }
  },
  "database": {
    "tables": [
      "krakenBlocksResourceContent",
      "krakenBlock"
    ]
  }
}

Resources aren’t elements in the MODX terminology at least - maybe you need to move that one level up in the json structure?

1 Like

Thanks a lot Markh, it did the trick, and just realize that I was missreading the structure part from the docs, although, after taking it out of the elements section, it creates the resource, but first, is just ignoring the published flag (its always unpublished), and after finishing the installation, the “Ok” button on GPM doesn’t get activated, like it was stucked or failed for any reason, any ideas?

After enabling full login inside modx im only getting this

(INFO @ /var/www/coreM0dXF1L3s/components/gitpackagemanagement/processors/mgr/gitpackage/create.class.php : 110) COMPLETED