getherbert / herbert

The WordPress Plugin Framework:
http://getherbert.com/
634 stars 95 forks source link

Cannot activate plugin - fresh install #172

Open falljer opened 7 years ago

falljer commented 7 years ago

Recently, I had ran "composer update" on a project I have been working on for the past several months to install a new plugin, and I started getting a fatal error on the Wordpress site if the Herbert plugin is enabled.

So, to narrow down the cause of the problem, I tried a fresh Wordpress install in my dev environment (downloaded today from wordpress.org) with a fresh Herbert download into the plugins directory, no customizations. Ran "composer install", and when I try to activate the plugin, I get the exact same message as my other project:

Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Unresolvable dependency resolving [Parameter #0 [ $app ]] in class Illuminate\Support\ServiceProvider in /Users/jeremyfall/Projects/wordpress/wp-content/plugins/herbert-dev/vendor/illuminate/container/Container.php:819 Stack trace: #0 /Users/jeremyfall/Projects/wordpress/wp-content/plugins/herbert-dev/vendor/illuminate/container/Container.php(757): Illuminate\Container\Container->unresolvablePrimitive(Object(ReflectionParameter)) #1 /Users/jeremyfall/Projects/wordpress/wp-content/plugins/herbert-dev/vendor/illuminate/container/Container.php(732): Illuminate\Container\Container->resolvePrimitive(Object(ReflectionParameter)) #2 /Users/jeremyfall/Projects/wordpress/wp-content/plugins/herbert-dev/vendor/illuminate/container/Container.php(708): Illuminate\Container\Container->resolveDependencies(Array) #3 /Users/jeremyfall/Projects/wordpress/wp-content/plugins/herbert-dev/vendor/illuminate/container/Container.php(565): Illuminate\Contai in /Users/jeremyfall/Projects/wordpress/wp-content/plugins/herbert-dev/vendor/illuminate/container/Container.php on line 819

If I can fix it, I will provide an update to the project, since I use Herbert a lot, and now it looks like I can't use it on any new projects, or update existing ones. But, I was hoping someone else had seen this, or could point me in the right direction here.

Thanks

ken-bem commented 7 years ago

On your composer.json file put "stable" in your minimum-stability field

falljer commented 7 years ago

Thanks @ken-bem that worked! Question though: does this mean something is changing in Illuminate/Container that will break Herbert long-term? I'm wondering if I should continue developing Wordpress plugins with Herbert if it's no longer being maintained.

ken-bem commented 7 years ago

Good that it did 💪🏽💪🏽. That is a good question, i feel there are 3 ways to tackle this problem:

  1. Make a repository with the stable version and only update when herbet is updated

  2. Make a repository and keep building in top of herbert, maybe even create a new herbert 👀( im thinkibg of doing this)

  3. Create your own framework from scratch

talss89 commented 7 years ago

Hi, sorry to hijack this issue, but I had the same problem as @falljer. Changing minimum-stability didn't help (and I did delete composer.lock and ./vendor).

Adding "illuminate/container": "~5.1.0" to my project's composer.json require section did fix the problem for me.

I think that might be preferable to changing minimum-stability.

Do you think it's worth a PR?

Tom.

ken-bem commented 7 years ago

Its definately worth a PR but you have to understand that it may take a while for someone to actually look at it, i suggest you create your own repository and make changes there, may help for new projects

webstractions commented 7 years ago

Thanks @talss89 for that fix.

acermez commented 7 years ago

Hi everyone, The origin of this issue is that the Illuminate\container::make() in version 5.4 is only accepting one argument instead of two. This could be fixed by changing all the calls to the container make() to makeWith() which is a replacement of the original make() at illuminate\container < 5.4 . Make sure to require 5.4.x-dev (at the time of this post, the makeWith() is not part of the latest 5.4 release). It is not a good solution off course as it is not permanent but if I can create a repo with the fix, I will post back. If anyone can point me how to merge the changes to this repo, that would be great. Thanks!

webstractions commented 7 years ago

@acermez The differences between 5.3 to 5.4 are causing a lot of problems, not just in this package, but everywhere. And yes, the fork and create your own solution is the common way to deal with it.

acermez commented 7 years ago

@webstractions, Thank you for pointing that out! I did not test it much after making it work, so I will try to give it more time and more real life scenarios as I really like how Herbert is handling backend panels and routing. I have been trying other packages such as Themosis Framework to build plugins, and still can't find a great one with easy backend routing and Laravel like flexibility.

webstractions commented 7 years ago

@acermez Themeosis seems to be on top of it. It is not a package to build plugins with, however. It is targeted at bridging Laravel with WordPress, and seems to do good job.

With that said, there probably is no right or wrong way of melding Laravel with WordPress. There are going to be some quirks.

I think projects like Herbert should not be advertised as a "plugin framework". It should be a Laravel Framework with WordPress as a dependancy. But that is just me.

giangmd commented 7 years ago

@talss89 Thanks. It's working for me now.

tranphuoctien commented 6 years ago

Hi All, i just fixed it! we need edit composer.json file

{ "name": "getherbert/herbert-plugin", "description": "Herbert plugin", "license": "MIT", "require": { "getherbert/framework": "~0.9", "illuminate/contracts": "v5.1.1" }, "config": { "preferred-install": "dist" }, "minimum-stability": "stable", "autoload": { "psr-4": { "GHNShipping\\": "app/" } } }

It's working for me.