1

I am starting to play with writing a plugin in Craft 3.0. I have followed the following page. I used Plugin Factory to create my plugin structure (very nice). My folder structure is as follows:

/craft
/craft/vendor/recoveryfinder/nav

I uploaded the files and folders created bt the pluginfactury to /craft/vendor/recoveryfinder/nav folder. My additions to the craft project composer.json look like this:

After:

{
  "name": "craftcms/craft",
  "description": "Craft CMS",

I added:

  "minimum-stability": "dev",
  "prefer-stable": true,

After:

  "scripts": {
    "post-root-package-install": [
      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
      "@composer dump-autoload -o",
      "@php craft setup/welcome"
    ]
  },

I added:

  "repositories": [
    {
      "type": "path",
      "url": "./vendor/recoveryfinder/nav"
    }
  ]

I went to the terminal logged in as the user that owns the files and change location to:

/craft

I then ran:

composer require recoveryfinder/nav

The output I am getting is:

Using version ^0.9.0 for recoveryfinder/nav
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals


  [RuntimeException]
  Package recoveryfinder/nav cannot install to "/home/recoveryfinder/craft/vendor/recoveryfinder/nav" inside its source at "/home/recoveryfinder/craft/
  vendor/recoveryfinder/nav"


require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...

I have not modified in any way the files created by pluginfactory.io.

Any pointers as to what I did wrong?

3

The article I wrote So You Wanna Make a Craft 3 Plugin? may help you in terms of figuring out how to properly set up a "host" website to run your plugin development from.

TL;DR your repo shouldn't point to your site's vendor directory, it should point to wherever that plugin exists on your local dev environment.

  • Thanks for that. I was all messed up in where I was putting files. You are correct. The plug in files should exist outside of craft and then composer sets things up in vendor. – Eric Snyder Mar 19 '18 at 0:20
0

The composer adds all necessary files into the vendor directory. You should never implement files there on your own so you should create a plugins folder next to your vendor folder and insert the files there. Your path parameter will then be /plugins/recoveryfinder/nav

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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