themosis / plugin

Themosis framework plugin boilerplate.
54 stars 19 forks source link

Got error when trying to activate the plugin using the Themosis 2.0 framework #17

Closed distributev closed 5 years ago

distributev commented 5 years ago

Using this plugin boilerplate I tried to create a plugin using the following setup

bedrockstructure-themosisplugin-sagetheme - https://roots.io/bedrock/ (Bedrock is installed fine)

Inside the plugin main folder composer.json I added themosis framework as a dependency like that

"require": { .... "themosis/framework": "2.0-beta2" }

then inside the plugin folder I executed composer.install ==> all deps where installed inside the plugin's vendor folder but then when I try to "Activate" the plugin I get

image

this is how the vendor folder looks like

image

jlambe commented 5 years ago

The boilerplate is not aimed to bootstrap the framework core classes. It's best to stick with the full stack than trying to install it as a plugin.

I won't provide support for custom installation. But in your case, I suppose you're missing the require call of the generated autoload.php file after running a composer install. Put the require statement as the first line and it may probably fix your issue.

distributev commented 5 years ago

I first tried to run the framework with an independent theme and got an error so then I tried to run the plugin with a different wordpress installation and got another error.

I'm not sure if themosis framework is aimed to be used in strict combination themosis framework, themosis plugin, themosis theme but I believe it would be beneficial to have each of these components independent of each other (maybe it will result in better overall solution - I'm not sure).

jlambe commented 5 years ago

The themosis/framework package is no longer a WordPress plugin. It is only a PHP package in its simplest form.

The themosis/themosis package is a WordPress stack which has as a dependency thethemosis/framework package. The stack is as well as the core package are independent but there is no longer any WordPress code inside the core package -> you have to bootstrap it on your own way. The theme is independant, sort of, it only needs the Themosis\Core\Application to be available otherwise you can't leverage the route API.

distributev commented 5 years ago

Julien , thank you for your help. I really appreciate your work this is why I am following your project since sometime and today I played all day with your stuff (and few hours some other time).

In regards with "The themosis/framework package is no longer a WordPress plugin. It is only a PHP package in its simplest form."

this is exactly what I was thinking and this is why I have imported "themosis/framework": "2.0-beta2" as a library into the plugin boilerplate. The framework being a PHP library and the plugin boiler plate being only a plugin boiler plate I would expect this combination to work fine.

However you said "it might work" and you also said "It's best to stick with the full stack than trying to install it as a plugin." In the end I might stick with the full Themosis stack (actually for the theme I really like Sage 9) but I would imagine all Themosis components being independent one of each other (the framework an independent PHP library which could be used in random WordPress plugins, the application as a custom wordpress installation (similar with bedrock) for people which want to automate the flow using git / composer and to also use Laravel like development in WordPress (bedrock does not have that, Themosis gives more here) and the theme , as an independent theme framework (similar with Sage 9).

I hope you'll take this as constructive feedback - My plan is to use Themosis in a pet project to see how it goes and then to move to more serious projects. It's been a long time since I am thinking "What is the easiest way to use Laravel for doing WordPress development?" and themosis is the closest I found to achieve that. Other than that there are random short blog entries which only touch the surface and say "if you use composer you can import some Laravel packages"

distributev commented 5 years ago

I added the require DIR . '/vendor/autoload.php'; as you suggested and then I got another error

require DIR . '/vendor/autoload.php';

image

and that is really strange I only installed WordPress using bedrock then added Sage as a theme and then added Themosis plugin boiler plate using themosis framework as a composer PHP library dependency.

I the screenshot I see a Sage exception that it cannot load a plugin. How come a theme "presentation" layer could try to load a plugin "backend layer" (and to fail) I would expect that themes / presentation layer will never influence the way that backend layer work. I suspect Sage is doing something bad here but I don't understand enough to say for sure. Bedrock is only installing WordPress using composer and has few folder changes but I don't think it does more than that.

distributev commented 5 years ago

or maybe the plugin boiler plate expects a custom "Themosis" application wordpress installation and in this case I believe it would be better if the plugin boiler plate would work indenpend on the Themosis application. There are plugin boiler plates with 5.3k github starts so if your pluging boiler plate will offer "Laravel" development inside plugins and will work on any WordPress ==> in this case will become very attractive for the WordPress community.

There is another plugin boiler plate https://github.com/getherbert/herbert which also adds composer and a little bit of Laravel inside WordPress and it follows a similar architecture like yours they also have a "framework" library - they got 600 stars on github (people need this) the problem is that the project is now dead.

https://github.com/getherbert/herbert

https://github.com/getherbert/framework/blob/dev/composer.json

https://github.com/getherbert/docs/blob/0.9/index.md

Bottom line is that I understand why the plugin boiler plate will import the themosis framework library and this should work fine (if people will need to import this library) but I don't think that the boiler plate should care if it is running on Themosis WordPress or Bedrock WordPress or a classic godaddy wordpress.

jlambe commented 5 years ago

The plugin boilerplate is indeed expecting the core package to be installed as it requires the Themosis\Core\Application class as well as the Themosis\Core\PluginManager class in order to bootstrap. The first line inside the root plugin file is calling the Application instance and its loadPlugin method.

Normally the plugin should have a use Themosis\Core\Application statement in order to import to correct class. It seems that the framework and Roots use the same container instance (singleton) and it seems that in your case sage has already bootstrapped his service container before you include your autoloading statement. So the plugin boilerplate has a "sage" container already instantiated and the Sage implementation does not have a loadPlugin method defined.

So it seems that Bedrock / Themosis cannot work together.

Also I won't plan to load the core package from a plugin specifically. The issue will be that if people want to develop multiple plugins, you end up with each plugin having a copy of the same dependencies loaded several times. This is not efficient. This is why it is best to use the themosis/themosis full stack, so dependencies for your application are loaded only once.

distributev commented 5 years ago

I found this - if it is relevant with our discussion

image

This is why it is best to use the themosis/themosis full stack, so dependencies for your application are loaded only once.

The issue with that is that I believe it might reduce exponentially the number of your pottential themosis users. For instance, in my situation, because I really want to use Sage 9 for this feature (Bootstrap 4, Bulma, Foundation, Tachyons. Or no CSS framework! You’re no longer tied into any specific CSS framework out of the box) and because Sage 9 cannot work with any part of Themosis I will probably not use anything from Themosis (though I tried separately the app, the plugin boiler plate, the framework but none worked independently with Sage 9) I would have happily used your plugin boiler plate with Sage 9 or your framework with Sage 9, or a combination like this - if this would have been possible.

https://roots.io/sage-9/

Meenwhile I tried the Herbert plugin and I got a similar strange error. I was about to try to most classic plugin boiler plate ever https://github.com/DevinVinson/WordPress-Plugin-Boilerplate but now I'm thining that the Bedrock autoloader mechanism is creating troubles.

Not related with our discussion. I saw you are from Arlon. I live in Luxembourg :-)

jlambe commented 5 years ago

You should check the new theme. By default there is no CSS framework involved so it's very easy to add the one you like (Bootstrap, ...) and with the implementation of Laravel Mix, the configuration is very easy and flexible.

Also not related to the discussion and as you live nearby, we can probably meet one time and discuss about this with a drink ;)

distributev commented 5 years ago

Yes, I owe you a drink :-) you are a good developer, so it will be my pleasure.

I have a strong Java enterprise background where for many years and because they were able to sell like that, people tried to do frameworks more and more "all or nothing" with the scope of getting their users 100% dependent on them, but now with the pressure of other languages, or of many github light libraries (and microservices) they are all doing the opposite. which is to make small, independent pieces, which you can use if you need and combine with other usefull stuff from other vendors - now in java the word "light" is the most used word :-)

distributev commented 5 years ago

Using bedrock and sage I finally managed to activate this plugin

https://github.com/DevinVinson/WordPress-Plugin-Boilerplate

then I added myself composer.json and installed CMB2 and it was working fine activation / deactivating.

Similary I can add other laravel packages which are useful (like database). Both themosis and roots.io are good but unfortunately they don't play nice together.