wecodemore / wpstarter

Easily bootstrap whole site Composer packages for WordPress.
https://wecodemore.github.io/wpstarter/
MIT License
246 stars 35 forks source link

[WPStarter 3 ]Requested packages wpstarter "^3" and batcache "1.3.*" produces "Problem" errors. #82

Closed akolbo closed 5 years ago

akolbo commented 5 years ago

Describe the bug Requested packages wpstarter "^3" and batcache "1.3.*" produces "Problem" errors.

To Reproduce Steps to reproduce the behavior:

  1. Use the example composer.json code from the docs found here: https://github.com/composer/composer/issues/6009
  2. Run composer install
  3. See error

Problem 1

  • The requested package frc/batcache 1.3.* is satisfiable by frc/batcache[v1.3-a1, v1.3-a2] but these conflict with your requirements or minimum-stability. Problem 2
  • The requested package wecodemore/wpstarter ^3 is satisfiable by wecodemore/wpstarter[3.x-dev, v3.0.0-beta.1] but these conflict with your requirements or minimum-stability.`

Expected behavior Composer would install the required dependencies.

composer.json:

{
    "name": "my-company/my-project",
    "type": "project",
    "license": "proprietary",
    "repositories": [
      {
        "type": "composer",
        "url": "https://wpackagist.org"
      }
    ],
        "require": {
        "composer/installers": "^1.6",
        "wecodemore/wpstarter": "^3",
        "johnpbloch/wordpress": "4.9",
        "inpsyde/wonolog":"^1",
        "wpackagist-plugin/wordfence":">=7.1.14",
        "wpackagist-plugin/memcached":"3.0.*",
        "frc/batcache": "1.3.*",
        "wpackagist-plugin/timber-library": "1.9.*",        
        "upstatement/timber-starter-theme": "2.x-dev"   
    },
    "extra": {
        "installer-paths": {
            "public/wp-content/plugins/{$name}": [
                "type:wordpress-plugin"
            ],
            "public/wp-content/mu-plugins/{$name}": [
                "type:wordpress-muplugin"
            ],
            "public/wp-content/themes/{$name}": [
                "type:wordpress-theme"
            ],
            "public/wp-content/{$name}": [
                "type:wordpress-dropin"
            ]
        },
        "wordpress-content-dir": "public/wp-content",
        "wordpress-install-dir": "public/wp"
    }
  }

wpstarter.json:

{
  "register-theme-folder": true,
  "content-dev-dir": "./",
  "dropins": [
    "./public/wp-content/plugins/memcached/object-cache.php",
    "./public/wp-content/mu-plugins/batcache/advanced-cache.php"
  ],
  "wp-cli-commands": "./scripts/wp-cli-commands.php"
}

scripts/wp-cli-commands.php

<?php
namespace WeCodeMore\WpStarter;

$env = new Env\WordPressEnvBridge();

// If env configuration is invalid nothing to do.
if (!$env->read(Util\DbChecker::WPDB_ENV_VALID)) {
    return [];
}

// If WP already installed, let's just tell WP CLI to check it.
if ($env->read(Util\DbChecker::WP_INSTALLED)) {
    return ['wp db check'];
}

$commands = [];

// If DB does not exist, let's tell WP CLI to create it.
if (!$env->read(Util\DbChecker::WPDB_EXISTS)) {
    $commands[] = 'wp db create';
}

// Build install command.
$user = $env->read('MY_PROJECT_USERNAME') ?: 'admin';
$home = $env->read('WP_HOME');
$siteUrl = $env->read('WP_SITEURL') ?: $home;
$email = "{$user}@" . parse_url($home, PHP_URL_HOST);
$install = "wp core install";
$install .= " --title='WP Starter Example' --url={$home}";
$install .= " --admin_user='{$user}' --admin_email='{$email}'";

// Add install command plus commands to update siteurl option and setup language.
$commands[] = $install;
$commands[] = "wp option update siteurl {$siteUrl}";
$commands[] = 'wp language core install it_IT';
$commands[] = 'wp site switch-language it_IT';

return $commands;

I can change the composer.json dependencies to this:

"wecodemore/wpstarter": "v3.0.0-beta.1", and "frc/batcache": "v1.3-a2",

And it works. Is that the best way?

gmazzap commented 5 years ago

Hi @akolbo

the problem you're seeing is not specific to WP Starter nor to batcache, but comes from Composer, and specifically with the minimum-stability flag.

When this is not set, Composer will default to stable meaning that only packages marked as stable will be installed. WP starter 3 is currently in beta, so is not stable. Regarding frc/batcache its non-standard version name let Composer think that it is not stable as well.

You hae 2 ways to solve the issue:

  1. Set minimum-stability to dev in your composer.json, which will tell Composer you are ok installing any non-stable packages
  2. Tell Composer that you are ok installing non-stable for just those packages which are causing issues. This is basically what happen when you require the packages using the exact version. If you want more flexibility than using the exact version, you could use @dev stability flag and e.g. require "wecodemore/wpstarter": "^3@dev" and "frc/batcache": "^1.3@dev".

Hope this helps.

akolbo commented 5 years ago

Thanks so much for the detailed response @gmazzap. Helps a lot!