Sage 10 first steps

Starting with Sage 10, I have a hard time understanding the use of Acorn.

I have seen that there are wp acorn commands for example using https://github.com/Log1x/acf-composer

wp acorn vendor: publish --provider = "Log1x \ AcfComposer \ Providers \ AcfComposerServiceProvider"

Should I install wp-cli outside of the Vagrant box to run the command? How does it work?

No.

What are you trying to do with it? The publish command is essentially the same as Laravel’s: Package Development - Laravel 7.x - The PHP Framework For Web Artisans It’s a convenience tool to copy some files from the package to your theme.

Just get Log1x/acf-composer working. Readme says:

Getting Started

Start by publishing the config/acf.php configuration file using Acorn:
$ wp acorn vendor:publish --provider="Log1x\AcfComposer\Providers\AcfComposerServiceProvider"

Also there is a command for generate field example:
wp acorn acf:field Example

Really I do not understand this. How and where can I run these commands?

When you run those commands, are you getting an error of some kind? If so what error?

Acorn itself is a package that brings the vast majority of Laravel into a Sage project, so you can use Laravel stuff to build themes, plugins, etc. You can reference the Laravel documentation for handling a lot of things you would do with Acorn.

Both of those commands explain what the do in the readme, so I’m not sure what you’re asking about. wp acorn vendor:publish will copy the config file for acf-composer to your theme. wp acorn acf:field Example will

…create src/Fields/Example.php which is where you will create and manage your first field group.

Both of these commands are optional: You don’t need to use them to set up acf-composer if you don’t want to. You can manually copy the acf config file, although it isn’t needed for the package to work. You can also manually create field definitions–they’re just classes with some special configuration. You can see the stubs that the cli command generates them from here: https://github.com/Log1x/acf-composer/tree/master/src/Console/stubs

Thank you for the explanation, Ben. I think the example field will be useful to see the folder and file structure (related to ACF fields) inside Sage 10 theme. So, I would like, at least, run wp acorn acf:field Example command. As far as I know (not so far :slight_smile: ) commands starting with wp are wp-cli commands and I get ‘command not found’ outside virtual machine.

commands starting with wp are wp-cli commands and I get ‘command not found’ outside virtual machine.

That’s correct, these are WP-CLI commands. You would need to ssh into your VM, or set up a WP-CLI alias to access them, as with any other WP-CLI command.

You may be able to set up WP-CLI on your host system and run these commands that way, but I don’t generally like to do that–some commands expect the presence of a valid WP installation and will fail if they can’t find it. Also I prefer not to use host-level systems to interact with guest-level stuff any more than I have to.

Ok, I am narrowing down the problem. If i run wp acorn acf:field Example inside web folder of bedrock project in the virtual machine I get:

There are no commands defined in the "acf" namespace.

did I do something wrong?

How and where did you initially install acf-composer?

Yes. That is! I installed it in bedrock instead sage. :sweat:

Thank you so much for the help.

1 Like

This topic was automatically closed after 42 days. New replies are no longer allowed.