boxybird / inertia-wordpress

The WordPress adapter for Inertia.js.
171 stars 26 forks source link

Composer support #19

Open tgeorgel opened 1 year ago

tgeorgel commented 1 year ago

Hi there, first of all thanks for your amazing work !

I've seen you added the type="wordpress-plugin" in the composer.json on master so we can use composer to get the plugin, that's cool !

However, the plugin still expect use to run composer install inside the plugin :

Capture d’écran 2022-10-20 à 08 51 50

Any idea how to fix this ?

Thanks !

boxybird commented 1 year ago

Hey @tgeorgel, thanks for the kind words.

To be honest, a contributor added "type='wordpress-plugin'" in a previous PR (https://github.com/boxybird/inertia-wordpress/pull/17) and it's a feature I don't take advantage of, nor fully understand.

That said, assuming you've chose the install path from the README, the error your getting might be because the required vendor/autoload.php file doesn't exist in the root of your theme. Or plugin, if you went that direction.

Sorry if that comes off as basic "composer" advice. I'm just hoping for an easy win!

mortensassi commented 1 year ago

@tgeorgel @boxybird I think now the problem is that since it is marked as a "wordpress-plugin", it will be automatically moved to the plugins-folder which requires a user to run composer install after installing. Not very convenient.

I guess you should remove the type declaration (again) in order to get this plugin moved into the vendors directory by default in order to make it work without any further steps. PLUS anyone who needs this plugin to be moved to the plugins directory should extend his/her composer.json like this:

// composer.json created by roots/bedrock
"extra": {
    "installer-paths": {
      "web/app/mu-plugins/{$name}/": [
        "type:wordpress-muplugin",
        "advanced-custom-fields/advanced-custom-fields-pro",
        "bostondv/acf-ninja-forms",
        "wpackagist-plugin/timber-library",
        "wpackagist-plugin/svg-support",
        "mortensassi/acf-svg-icon",
        "ooksanen/acf-focuspoint",
        "vinkla/headache",
        "wpackagist-plugin/svg-support"
      ],
      "web/app/plugins/{$name}/": [
      "type:wordpress-plugin",
     "boxybird/inertia-wordpress" // <<--- here
      ],
      "web/app/themes/{$name}/": ["type:wordpress-theme"]
    },
    "wordpress-install-dir": "web/wp"
  },