3

I set up a basic plugin using https://pluginfactory.io/

The package name is kgrote

The plugin name is siteutilities

Then I put it in a subfolder next to my Craft project folder:

/site
|-- craft
|-- craft-plugins
  |-- kgrote
    |-- siteutilities

Then I added this to craft/composer.json:

"minimum-stability": "dev",
"prefer-stable": true,
"repositories": [
    {
      "type": "path",
      "url": "../craft-plugins/kgrote/siteutilities"
    }
]

Then I ran this command in the Craft project folder:

composer require kgrote/siteutilities

Then I got this error:

Could not find a matching version of package kgrote/siteutilities. Check the package spelling, your version constraint and that the package is available in a stability which matches your minimum-stability (stable).

Here is the contents of my craft/composer.json file:

{
  "require": {
    "craftcms/cms": "3.0.23.1",
    "vlucas/phpdotenv": "^2.4.0",
    "craftcms/aws-s3": "1.0.8",
    "craftcms/redactor": "2.1.6",
    "ether/seo": "3.4.3"
  },
  "autoload": {
    "psr-4": {
      "modules\\": "modules/"
    }
  },
  "config": {
    "optimize-autoloader": true,
    "platform": {
      "php": "7.0"
    }
  },
  "scripts": {
    "post-root-package-install": [
      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ]
  },
  "minimum-stability": "dev",
  "prefer-stable": true,
  "repositories": [
    {
      "type": "path",
      "url": "../craft-plugins/kgrote/siteutilities"
    }
  ]
}

And here is the contents of my plugin composer.json file:

{
    "name": "kgrote/site-utilities",
    "description": "Helper functions for this website.",
    "type": "craft-plugin",
    "version": "1.0.0",
    "keywords": [
        "craft",
        "cms",
        "craftcms",
        "craft-plugin",
        "site utilities"
    ],
    "support": {
        "docs": "???",
        "issues": "???"
    },
    "license": "MIT",
    "authors": [
        {
            "name": "Kristen Grote"
        }
    ],
    "require": {
        "craftcms/cms": "^3.0.0-RC1"
    },
    "autoload": {
        "psr-4": {
          "kgrote\\siteutilities\\": "src/"
        }
    },
    "extra": {
        "name": "Site Utilities",
        "handle": "site-utilities",
        "hasCpSettings": false,
        "hasCpSection": false,
        "changelogUrl": "???",
        "class": "kgrote\\siteutilities\\SiteUtilities"
    }
}

Don't really know what I'm doing wrong here. How does composer know what kgrote/siteutilities is if it's not defined in the composer.json file? Shouldn't that be part of the "repositories" config setting?

2
  • 1
    You may need to paste your composer file for the plugin itself and your full project composer file to help us work out exactly what the problem is. In the past I’ve had to delete my vendors directory and composer lock file to force composer to fetch everything fresh.
    – Jay
    Sep 9, 2018 at 8:48
  • @Jay Updated with composer.json files.
    – kmgdev
    Sep 10, 2018 at 0:44

2 Answers 2

5

From looking at your plugin's composer.json file, I think you've got the package name wrong – instead of

composer require kgrote/siteutilities

you'll probably want

composer require kgrote/site-utilities

I.e. the plugin folder's name doesn't matter – it's the name entry in your plugin's composer.json file that determines the package name.

1
  • That was the problem, thanks! Also explains how composer knows what the package name is.
    – kmgdev
    Sep 13, 2018 at 19:23
1

Adding kgrote/siteutilities to your "require" section in your main composer file then changing your "name" in the plugin composer file to match should help.

Don't forget to update the plugin version number to try to force composer top get the latest versions. I've found it caches in the Vendors directory though. So make the above changes and delete the composer.lock file and the Vendors directory and install everything from scratch.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.