Carbon Fields when required by Composer needs to live in the public WP directory. You can fix that easily enough here: [https://carbonfields.net/docs/guides-bedrock-support/](CF + Bedrock guide). When deploying with Trellis I started getting autoloader exceptions for Carbon Fields from the wp-cli during the deploy.
Finally figured out that Carbon Fields was not making it into the Bedrock web/wp directory on the first pass of composer install. I went into the site install and manually ran composer install and boom it all works since there is a web/wp to stick CF into when composer install runs the second time . I edited the after-build hook that calls composer install to simply call composer install twice in a row. I got it working, yet is there a better way to solve this issue?
Why are you trying to put it in web/wp? The guide doesn’t mention anything about that location, and generally nothing should go there. The public directory for Bedrock is just web, so I feel like you should be able to just do
When I set CF to install into web/vendor, autoload works fine yet CF tries to serve its assets for displaying the actual fields from the wp directory instead of the web/vendor directory. (The CF container shows up, just not the actual fields for editing. I also get a whole slew of 404s in the developer console for the CF css/js)
When CF installs into web/wp, everything works as expected on the CF side. I just have to use my silly hack of two composer calls in a row to get CF into where it wants to be.
For now, I’ll go with the double composer calls. This is a CF issue more than a trellis/bedrock issue.
So maybe you could set that constant to the correct url and bypass the logic that’s giving you a bad URL? It looks like the url logic also supports Carbon Fields being installed as a plug-in, so maybe you could for Composer to install it as a plug-in as a possible solution too.
You sir are a wizard. You went above and beyond, which I certainly appreciate. Thank you for digging into the CF code. Defining the URL constant before booting CF did the trick. Below is the snippet that got me rolling again.