boxybird / inertia-wordpress

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

Create a composer package instead of a wordpress plugin #3

Closed merijnponzo closed 3 years ago

merijnponzo commented 3 years ago

Since i already need to run a composer install within the plugin's directoy of the wordpress-inertia-plugin, I think it's more likely to a add the wordpress-inertia adapter within my theme files, with composer.

Just like the timber v2 installation https://timber.github.io/docs/v2/installation/

If there is an inertia update, i can check the composer file within my theme. Or your starter theme.

boxybird commented 3 years ago

A composer package does make sense. Just added it: https://packagist.org/packages/boxybird/wordpress-inertia-plugin.

merijnponzo commented 3 years ago

Thank you for wrapping it up as a composerpackage.

I referenced to timber since they went from plugin to only a vendor Package within your wordpress theme.

Since its unlikely i would upgrade the boxybird inertia adapter from plugins, and deactivating would break the site it should only live as a composer vendor folder within my theme.

Another benefit would be that you start right away with the boxybird theme, since the inertia adapter would live within the composer file within the theme.

I know this would mean a bit of refactoring :-)

boxybird commented 3 years ago

Reopening this. Looks like supporting the package as a composer dependency needs some work. Will refactor in the future. For now, you should install the plugin via the WordPress admin.

boxybird commented 3 years ago

Resolved composer install issues.

merijnponzo commented 3 years ago

Hellow, any updates on installing the wordpress-inertia-adapter as a vendor file instead of plugin?

Meanwhile based on your wordpress theme I got it working with ViteJs and Vue3 https://github.com/merijnponzo/innervite2

With

resolve: {
    alias: {
      vue: 'vue/dist/vue.esm-bundler.js',
    },
  },

and

 vue3-runtime-template

It's compiling vue-components fromout the lazyblocks plugin on the fly, pretty cool.

boxybird commented 3 years ago

@merijnponzo Yes, the composer package is ready. I've already used it a couple of projects. It's so much more convenient to use over the plugin. Thanks for the push.

Vite is awesome! Glad you got it to work with Inertia.

merijnponzo commented 3 years ago

Hi, can you share the composer package? Awesome

boxybird commented 3 years ago

I put it in the readme: https://github.com/boxybird/wordpress-inertia-plugin#installation

merijnponzo commented 3 years ago

Nice! Actually i ment:

To install Boxybird-Inertia, navigate to your theme directory run

composer require boxybird/wordpress-inertia-plugin

If your theme or project is not already set up to pull in Composer’s autoload file, you will need to add the following line at the top of your functions.php file:

<?php
// load composer
if (!file_exists($autoload = __DIR__ . '/vendor/autoload.php')) {
    die('This theme requires composer autoload, please run "composer install"');
}
require_once $autoload;

That's it. Since my theme has no viability without the plugin I always should install it within my theme folder. This means you can even drop call it a plugin :-)

Just call it wp-inertia would be enough :-) That said, i respect your great effort by building this plugin and the example theme.

I will finish my boilerplate theme by any time now

boxybird commented 3 years ago

@merijnponzo Hello! I again for the kind words!

I think we're on the same page.

To install Boxybird-Inertia, navigate to your theme directory run

composer require boxybird/wordpress-inertia-plugin

// load composer if (!file_exists($autoload = DIR . '/vendor/autoload.php')) { die('This theme requires composer autoload, please run "composer install"'); } require_once $autoload;

You can already do this ^. Are you having issues installing it as a theme dependency?

That said, it looks like I should make some changes to the readme to make this more clear.

As far as renaming the repo, I'd like to make sure there are no downsides before I do. I'll look into it...

anoblet commented 3 years ago

@boxybird Is there a reason why the composer package is no longer available?

boxybird commented 3 years ago

@anoblet The composer is still available: https://github.com/boxybird/inertia-wordpress#installation

I did change the repo name recently to better align with the official Inertia adapters. Is composer require boxybird/inertia-wordpress not working for you?

anoblet commented 3 years ago

Ah, got it!