soberwp/models

Can't install

robrecord opened this issue ยท 12 comments

Sorry, is this a bug or can you tell me what I'm doing wrong?

I'm installing via composer - always have been able to install plugins this way - and the plugin isn't showing up. It looks like it's saving it to the wrong directory.

$ composer require soberwp/models

Using version ^1.0 for soberwp/models
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 3 installs, 0 updates, 0 removals
  - Installing symfony/yaml (v3.4.8): Loading from cache
  - Installing hassankhan/config (0.10.0): Loading from cache
  - Installing soberwp/models (1.0.6-p): Loading from cache
symfony/yaml suggests installing symfony/console (For validating YAML files using the lint command)
Writing lock file
Generating autoload files


$ wp plugin activate models

Warning: The 'models' plugin could not be found.
Error: No plugins activated.


$ ls web/app/plugins/

advanced-custom-fields-pro  gutenberg        soil
disable-emojis              home-page-block  wordfence

$ ls vendor/soberwp/

models


$ cat composer.json

{
  "name": "roots/bedrock",
  "type": "project",
  "license": "MIT",
  "description": "WordPress boilerplate with modern development tools, easier configuration, and an improved folder structure",
  "homepage": "https://roots.io/bedrock/",
  "authors": [
    {
      "name": "Scott Walkinshaw",
      "email": "scott.walkinshaw@gmail.com",
      "homepage": "https://github.com/swalkinshaw"
    },
    {
      "name": "Ben Word",
      "email": "ben@benword.com",
      "homepage": "https://github.com/retlehs"
    }
  ],
  "keywords": [
    "bedrock", "roots", "wordpress", "stack", "composer", "vagrant", "wp"
  ],
  "support": {
    "issues": "https://github.com/roots/bedrock/issues",
    "forum": "https://discourse.roots.io/category/bedrock"
  },
  "config": {
    "preferred-install": "dist"
  },
  "repositories": [
    {
      "type": "composer",
      "url": "https://wpackagist.org"
    },
    {
      "type": "package",
      "package": {
        "name": "deliciousbrains/wp-migrate-db-pro",
        "type": "wordpress-plugin",
        "version": "1.8.1",
        "dist": {
          "type": "zip",
          "url": "https://deliciousbrains.com/dl/wp-migrate-db-pro-latest.zip?"
        },
        "require": {
          "composer/installers": "^1.0",
          "igniteonline/wpm-pro-installer": "^1.0.2"
        }
      }
    },
    {
      "type": "package",
      "package": {
        "name": "deliciousbrains/wp-migrate-db-pro-media-files",
        "type": "wordpress-plugin",
        "version": "1.4.9",
        "dist": {
          "type": "zip",
          "url": "https://deliciousbrains.com/dl/wp-migrate-db-pro-media-files-latest.zip?"
        },
        "require": {
          "composer/installers": "^1.0",
          "igniteonline/wpm-pro-installer": "^1.0.2"
        }
      }
    },
    {
      "type": "package",
      "package": {
        "name": "deliciousbrains/wp-migrate-db-pro-cli",
        "type": "wordpress-plugin",
        "version": "1.3.2",
        "dist": {
          "type": "zip",
          "url": "https://deliciousbrains.com/dl/wp-migrate-db-pro-cli-latest.zip?"
        },
        "require": {
          "composer/installers": "^1.0",
          "igniteonline/wpm-pro-installer": "^1.0.2"
        }
      }
    },
    {
      "type": "package",
      "package": {
        "name": "advanced-custom-fields/advanced-custom-fields-pro",
        "version": "5.6.9",
        "type": "wordpress-plugin",
        "dist": {
          "type": "zip",
          "url": "https://connect.advancedcustomfields.com/index.php?p=pro&a=download"
        },
        "require": {
          "philippbaschke/acf-pro-installer": "^1.0",
          "composer/installers": "^1.0"
        }
      }
    }
  ],
  "require": {
    "php": ">=5.6",
    "composer/installers": "^1.4",
    "vlucas/phpdotenv": "^2.0.1",
    "johnpbloch/wordpress": "4.9.4",
    "oscarotero/env": "^1.1.0",
    "roots/wp-password-bcrypt": "1.0.0",
    "roots/soil": "^3.7",
    "advanced-custom-fields/advanced-custom-fields-pro": "*",
    "wpackagist-plugin/wordfence": "^7.1",
    "wpackagist-plugin/disable-emojis": "^1.7",
    "wpackagist-plugin/gutenberg": "^2.4",
    "soberwp/models": "^1.0"
  },
  "require-dev": {
    "squizlabs/php_codesniffer": "^3.0.2"
  },
  "extra": {
    "installer-paths": {
      "web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin"],
      "web/app/plugins/{$name}/": ["type:wordpress-plugin"],
      "web/app/themes/{$name}/": ["type:wordpress-theme"]
    },
    "wordpress-install-dir": "web/wp"
  },
  "scripts": {
    "post-root-package-install": [
      "php -r \"copy('.env.example', '.env');\""
    ],
    "test": [
      "phpcs"
    ]
  }
}

did you get this working?

Models is a "type": "wordpress-muplugin" or package (the *-p version), so it shouldn't have to be activated. Install it with composer and that's all

Closing for now.

@darrenjacoby Sorry I did get this working, not sure how but I just tried it again at a later date. Something else must have been out of place.

Really enjoying using the plugin so far, thank you for building it!

@robrecord glad to hear!

Also, thank you @palmiak - I think it was indeed this fundamental misunderstanding that led me astray!

This is happening to me again... A completely fresh install of WP using bedrock, and models is the first thing I try to install:

$ composer require soberwp/models

Using version ^1.0 for soberwp/models
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 4 installs, 0 updates, 0 removals
  - Installing symfony/polyfill-ctype (v1.8.0): Loading from cache
  - Installing symfony/yaml (v3.4.11): Loading from cache
  - Installing hassankhan/config (0.10.0): Loading from cache
  - Installing soberwp/models (1.0.6-p): Loading from cache
symfony/yaml suggests installing symfony/console (For validating YAML files using the lint command)
Writing lock file
Generating autoload files

$ wp plugin activate models
Warning: The 'models' plugin could not be found.
Error: No plugins activated.

$ wp plugin list --status=must-use
+--------------------------+----------+--------+---------+
| name                     | status   | update | version |
+--------------------------+----------+--------+---------+
| bedrock-autoloader       | must-use | none   | 1.0.0   |
| disallow-indexing        | must-use | none   | 1.0.0   |
| register-theme-directory | must-use | none   | 1.0.0   |
+--------------------------+----------+--------+---------+

This is before installing sage. Does it only work with Sage?

Your instructions say to do wp plugin install - is that wrong?

Do I have to install it in bedrock and in sage, or are your instructions suggesting one or the other?

(I believe the thing that allowed me to get it working before is that I installed it manually.)

I can see it's installed to /vendor, and the composer.json still states the type is "package" and not "muplugin":

$ cat vendor/soberwp/models/composer.json
{
  "name": "soberwp/models",
  "type": "package",
  "license": "MIT",
  "description": "WordPress plugin to create custom post types and taxonomies using JSON, YAML or PHP files.",
  "homepage": "https://github.com/soberwp",
  "authors": [
    {
      "name": "Darren Jacoby",
      "email": "darren@jacoby.co.za",
      "homepage": "https://github.com/darrenjacoby"
    }
  ],
  "keywords": [
    "wordpress"
  ],
  "support": {
    "issues": "https://github.com/soberwp/models/issues"
  },
  "require": {
    "php": ">=5.6",
    "composer/installers": "~1.0",
    "hassankhan/config": "^0.10.0",
    "symfony/yaml": "^3.3"
  },
  "require-dev": {
    "squizlabs/php_codesniffer": "2.*"
  },
  "autoload": {
    "psr-4": {
      "Sober\\Models\\": "src/",
      "Sober\\Models\\Model\\": "src/Model/"
    },
    "files": [
      "models.php"
    ]
  },
  "scripts": {
    "test": [
      "vendor/bin/phpcs --extensions=php --ignore=vendor/ ."
    ]
  }
}

OK this is how I got it working:

I realised there are two versions of the project: package and mu-plugin. The package just doesn't do anything with wordpress out of the box.
Asking for the latest version in composer will always retrieve the package, as in 1.0.6-p
The only way I can see to get the non-package (mu-plugin) version is to specify the exact version with no caret, such as 1.0.6:

$ composer remove soberwp/models
...
$ composer require soberwp/models:1.0.6

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 4 installs, 0 updates, 0 removals
  - Installing symfony/polyfill-ctype (v1.8.0): Loading from cache
  - Installing symfony/yaml (v3.4.11): Loading from cache
  - Installing hassankhan/config (0.10.0): Loading from cache
  - Installing soberwp/models (1.0.6): Downloading (100%)
symfony/yaml suggests installing symfony/console (For validating YAML files using the lint command)
Writing lock file
Generating autoload files

I can now see Models as having been autoloaded in my mu-plugins list in the Wordpress web admin.

Can you make this a little easier for us somehow? Thank you!

I think that the only is thing that can be done is correcting the readme (no install step) and composer.json (so it install the mu-plugin by default).

I proposed it in PR - #11 - @robrecord do you think this would be clear enough?

That might do the trick for new users, yes. Thank you @palmiak - I guess this PR needs implementing urgently because it's a major barrier for new users.

My only reservation is that you can't do composer update and have the latest version - this doesn't seem possible with your current versioning scheme, as 1.0.6 will always update to 1.0.6-p. I would love to see a way for that to be rectified.

I would also like to see a line that says, for clarity, that you can install within Bedrock or in Sage but it's not necessary to do both.

However, the changes you suggested will fix the immediate barriers that I encountered.

I responded on the PR (and merged).