pivvenit / acf-composer-bridge

Provides a static composer repository that references all Advanced Custom Fields Pro versions
MIT License
47 stars 8 forks source link

Trouble defining the install folder #6

Closed Ariane-B closed 4 years ago

Ariane-B commented 4 years ago

With v2, the plugin properly installs to public_html/wp-content/plugins. However, when I tried to update to v3, it started stubbornly installing to vendor. I tried several things with my extra/installer-paths, to no avail. I don't think I did it right. Do you think you could provide examples in your readme to help us get ACF to install to the plugins folder?

With v2, my extra entry looks like this:

    "extra": {
        "installer-paths": {
            "vendor/{$name}/": [
                "type:composer",
                "composer/installers",
                "vlucas/phpdotenv"
            ],
            "public_html/wp-content/plugins/{$name}/": ["type:wordpress-plugin"]
        }
    }

I tried adding all sorts of things to the public_html/wp-content/plugins/{$name}/ array, as such:

"public_html/wp-content/plugins/{$name}/": [
"type:wordpress-plugin",
"type:advanced-custom-fields,
"advanced-custom-fields",
"advanced-custom-fields/advanced-custom-fields-pro",
"type:wpackagist-plugin"
]

All of these still result in ACF installing to vendor. I went back to v2 for now, but I wish I understood.

schliflo commented 4 years ago

this composer json works well here:

{
  "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", "composer", "roots", "wordpress", "wp", "wp-config"
  ],
  "support": {
    "issues": "https://github.com/roots/bedrock/issues",
    "forum": "https://discourse.roots.io/category/bedrock"
  },
  "repositories": [
    {
      "type": "composer",
      "url": "https://pivvenit.github.io/acf-composer-bridge/composer/v3/wordpress-muplugin/"
    },
    {
      "type": "composer",
      "url": "https://wpackagist.org"
    }
  ],
  "require": {
    "php": ">=7.1",
    "composer/installers": "^1.8",
    "vlucas/phpdotenv": "^4.1.0",
    "oscarotero/env": "^1.2.0",
    "roots/wordpress": "^5.3.2",
    "roots/wp-config": "^1.0.0",
    "roots/wp-password-bcrypt": "^1.0.0",
    "roots/soil": "^3.7",
    "wp-cli/wp-cli": "^2.1",
    "wp-cli/wp-cli-bundle": "^2.1",
    "advanced-custom-fields/advanced-custom-fields-pro": "^5.5",
    "wpackagist-plugin/wp-super-cache": "^1.6",
    "wpackagist-plugin/wordpress-seo": "^13.0",
    "wpackagist-plugin/google-site-kit": "^1.0"
  },
  "require-dev": {
    "squizlabs/php_codesniffer": "^3.5.4",
    "roave/security-advisories": "dev-master"
  },
  "config": {
    "optimize-autoloader": true,
    "preferred-install": "dist"
  },
  "minimum-stability": "dev",
  "prefer-stable": true,
  "extra": {
    "installer-paths": {
      "web/app/mu-plugins/{$name}/": [
        "type:wordpress-muplugin",
        "roots/soil",
        "advanced-custom-fields/advanced-custom-fields-pro",
        "wpackagist-plugin/wp-super-cache",
        "wpackagist-plugin/wordpress-seo",
        "wpackagist-plugin/google-site-kit"
      ],
      "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"
    ]
  }
}
Qrious commented 4 years ago

Do you think you could provide examples in your readme to help us get ACF to install to the plugins folder?

I think this is a good idea, i'll add several examples.

The config posted by @schliflo seems fine (i haven't tested it). However note that his config adds the plugin as mu-plugin instead of a normal plugin. In case you want to install advanced-custom-fields as a normal plugin, move the "advanced-custom-fields/advanced-custom-fields-pro" under extra.installer-paths.web/app/mu-plugins/{$name}/ to extra.installer-paths.web/app/plugins/{$name} key.

Qrious commented 4 years ago

Also note that this is only supported for the following types:

wordpress-plugin
wordpress-theme
wordpress-muplugin
wordpress-dropin
Ariane-B commented 4 years ago

Hi! I'm sorry to be back after so long.

I got it working, but only with the legacy wordpress-plugin type. I'm not sure I fully understand why, but whenever I use the repository URL https://pivvenit.github.io/acf-composer-bridge/composer/v3/wpackagist-plugin/, it stubbornly keeps installing to vendor/advanced-custom-fields.

Changing the repository URL to https://pivvenit.github.io/acf-composer-bridge/composer/v3/wordpress-plugin/, then it properly installs to wp-content/plugins.

Here is my full composer.json:

{
    "name": "nubee/produitsbcm",
    "description": "Produits BCM",
    "type": "project",
    "authors": [
        {
            "name": "David Ménard",
            "email": "david@nubee.ca"
        }
    ],
    "repositories":[
        {
            "type": "composer",
            "url": "https://pivvenit.github.io/acf-composer-bridge/composer/v3/wordpress-plugin/"
        },
        {
            "type":"composer",
            "url":"https://packagist.org"
        },
        {
            "type":"composer",
            "url":"https://wpackagist.org"
        }
    ],
    "require-dev":{
        "wpackagist-plugin/laravel-dd":"*"
    },
    "require": {
        "masterminds/html5": "^2.0",
        "vlucas/phpdotenv": "^3.0",
        "wpackagist-plugin/acf-autosize":"*",
        "wpackagist-plugin/acf-content-analysis-for-yoast-seo":"*",
        "wpackagist-plugin/advanced-access-manager":"*",
        "wpackagist-plugin/classic-editor":"*",
        "wpackagist-plugin/crop-thumbnails":"*",
        "wpackagist-plugin/disable-comments":"*",
        "wpackagist-plugin/disable-json-api":"*",
        "wpackagist-plugin/duplicate-post":"*",
        "wpackagist-plugin/duracelltomi-google-tag-manager":"*",
        "wpackagist-plugin/french-slugs":"*",
        "wpackagist-plugin/google-analytics-dashboard-for-wp":"*",
        "wpackagist-plugin/imsanity":"*",
        "wpackagist-plugin/intuitive-custom-post-order":"*",
        "wpackagist-plugin/redirection":"*",
        "wpackagist-plugin/regenerate-thumbnails":"*",
        "wpackagist-plugin/relevanssi":"*",
        "wpackagist-plugin/safe-svg":"*",
        "wpackagist-plugin/tinymce-advanced":"*",
        "wpackagist-plugin/wordpress-seo":"*",
        "wpackagist-plugin/wp-mail-smtp":"*",
        "wpackagist-plugin/wp-session-manager":"*",
        "wpackagist-plugin/wp-super-cache":"*",
        "wpackagist-plugin/wps-hide-login":"*",
        "wpackagist-plugin/disable-embeds": "*",
        "wpackagist-plugin/ewww-image-optimizer": "*",
        "wpackagist-plugin/disable-emojis": "*",
        "advanced-custom-fields/advanced-custom-fields-pro": "*"
    },
    "extra": {
        "installer-paths": {
            "public_html/wp-content/plugins/{$name}/": ["type:wordpress-plugin"],
            "vendor/{$name}/": [
                "type:composer",
                "composer/installers",
                "vlucas/phpdotenv"
            ]
        }
    }
}

I thought maybe our other installer-paths rule conflicted with the bridge, so I tried removing them entirely (I think they're only useful for our production server):

    "extra": {
        "installer-paths": {
            "public_html/wp-content/plugins/{$name}/": ["type:wordpress-plugin"]
        }
    }

But no, ACF still installs to vendor/advanced-custom-fields if I use the repository URL https://pivvenit.github.io/acf-composer-bridge/composer/v3/wpackagist-plugin/.

I don't know what else to try. For now I'll just use the wordpress-plugin URL as it works fine, but it somewhat bothers me to use something that's called "legacy". Do you think the problem might be on your side?

Qrious commented 4 years ago

This is due to the fact that the extra.installer-paths are parsed by the composer/installers package (https://github.com/composer/installers). As described in their readme under the supported types sections, for Wordpress they support only the following types:

Note the absense of wpackagist-plugin. That is why it is not working, since the installer doesn't handle this type.

I've just been looking for the reasoning behind it, and i could not find the reference to the legacy part about wordpress-plugin anymore (i swear it was on their homepage :O), so i'll remove it from our naming as well (and put it on top).

Ariane-B commented 4 years ago

Oh, that makes sense. Thank you very much! :)