I’m encountering a problem where my wp cli doesn’t recognize the acorn package.
Objective: I aim to develop a WordPress plugin using the acorn package.
Environment: I’m operating within a docker container, utilizing the “wordpress:cli-php8.2” docker image for WordPress cli. The docker image setup is fine, and I can use the wp cli tool without issues.
Additionally, I’ve installed the following package into the image for debugging purposes and to have composer available for the Acorn installation.
I attempted to install Acorn in a few ways with no success:
Executed “composer require roots/acorn” within the plugin folder, but it was unsuccessful.
Ran “composer require roots/acorn” at the root of the wp installation, , but it was unsuccessful.
To test I attempted the following variations of the command. wp acorn --allow-root --path=/var/www/html wp acorn --allow-root --path=/var/www/html/wp-content/plugins/plugin_dir wp acorn --allow-root
but received the…
error: ‘acorn’ is not a registered wp command.
I verified if the package was recognized by wp cli using wp package list --allow-root and found it wasn’t.
So, I tried the following:
Executed wp package install roots/acorn --allow-root. This just ran a composer install in the wp cli’s packages directory, which can be located by running: wp --info --allow-root, This caused wp package list --allow-root to claim the package was install but did not result in the command wp acorn being recorgnised.
Finally I attempted to install acorn globally via composer global require roots/acorn.
I’ve also run the composer post-dump-autoload script and the standard dump autoload.
Despite all attempts, I cannot seem to get the wp cli to recognize the ‘acorn’ command.
I was thrilled to discover that Acorn could introduce Laravel architecture to a WordPress plugin and was eager to start using it in my new project. However, I’m running out of time to resolve this before I need to forgo it and implement my own architecture. Any assistance would be immensely valuable as I’m quickly exhausting options and time to debug.
Are you using Bedrock? If your WordPress site itself isn’t managed with Composer then just requiring Acorn from your WP install root isn’t going to have any effect
I have not installed bedrock, I was under the impression that Acorn can run independently from the other roots packages to allows for a Laravel like architecture within a newly developed plugin.
This is what I gathered from this paragraph within the documentation.
“Acorn brings elements of the Laravel ecosystem to any WordPress plugin or theme.”
The installation documentation has no mention of any dependency on the bedrock package.
Does this mean Acorn will only work on top of Bedrock ? my understanding is that bedrock changes the entire infrastructure of the wp project and this is not what I am trying to achieve, I am trying to isolate my developments to the plugin folder only.
If Acorn does require Bedrock to function, could you point me to the documentation that say’s so please.
I have also listed all the alternative ways I have attempted the install however, you response suggest that the approach outlined in the attached should suffice, however this is still resulting in an issue.
Ok, my understanding is that this is wp cli commands tool extension.
The documentation of the Acorn package does not suggest that there are any additional step other than composer require roots/acorn which I imagine installs the package within the vendor folder > installs it’s dependencies from the roots/acorn composer.json > then runs any additional scripts to make it available within the wp cli tools available.
Could you tell me what I can do to successfully start using acorn, rather than what I can not do please.
If there are additional steps that I need to take like loading the autoloader of the vendor file, then please tell me.
As I stated earlier it is my understanding that Acorn can run independently within a plugin folder for a Laravel style plugin without any other plugins, If there are steps that need to be taken that I have missed could you please list them as I am sure this would help me and any others facing a similar issue.
Ok Ben, Even though I have stated that it is inside of the scenario that you have outlined and demonstrated that I have followed the documentation to a tee, it seems clear that help is to much effort. If I have done something incorrect than I would have welcomed you to outline it.