Closed pgrmCreate closed 8 years ago
Hi @pgrmCreate,
We've addressed this issue in a recent commit.
Do you mind trying with the latest development version of Carbon Fields? This should resolve your issue.
To do that, you can call composer require htmlburger/carbon-fields:dev-master
.
Looking forward to your reply.
Good afternood @tyxla,
I tryed this version of carbon-fields but i have the same problem. Just a little difference, logs saying : [Wed Mar 02 13:45:50.802307 2016] [:error] [pid 11761] [client 127.0.0.1:37455] PHP Fatal error: Call to undefined function trailingslashit() in /home/jb/projets/aljt/vendor/htmlburger/carbon-fields/carbon-fields.php on line 13, referer: http://localhost:3000/wp/wp-admin/plugins.php?plugin_status=all&paged=1&s
Can i try (coding) anything ?
Hey @pgrmCreate,
Carbon Fields needs essential WordPress functions in order to load and work properly. Bedrock appears to load the composer-loaded libraries before loading the WordPress core, which causes your issue.
You can fix this by doing the following:
/web/wp-config.php
.require_once()
. Move the require_once(dirname(__DIR__) . '/vendor/autoload.php');
line below the other 2 lines. This will load WordPress before loading the libraries.Please, let me know if that works for you.
Re @tyxla ,
I tryed this but i have same 500 error with this in logs apache : [Wed Mar 02 14:29:48.720947 2016] [:error] [pid 14767] [client 127.0.0.1:41318] PHP Fatal error: Class 'Env' not found in /home/jb/projets/aljt/config/application.php on line 9 In top of this file we can read this on comment :
I understand idea, i tryed import wp-load.php but without good result. The issue is maybe import in this order :
But we loose advantage of composer..
Maybe the better way is make a version for bedrock who the core is loaded before the carbon fields.
We'll consider implementing a fix so Carbon Fields will be usable as a composer package with Bedrock and similar environments.
In the meantime, consider using Carbon Fields as a plugin instead of a composer package.
Ok @tyxla, thanks you for your interventions and good cheer.
@pgrmCreate It's not really a Carbon Fields issue. You just can't put any WordPress plugin/package under the web root because it needs resources (static assets like JS files) that needs to be accessible from a URL. If you don't want to use it as a plugin, place it in your theme folder and load it from your functions.php
file, juste like other packages/libraries do.
@tyxla You should probably change the type of your composer.json file, "wordpress-plugin" will probably be a better choice as it will directly be installed at the right location. See: https://github.com/roots/bedrock/blob/master/composer.json#L45
@nlemoine thanks for the good points. We'll have them under consideration. Keeping this issue open in the meantime. Stay tuned.
I tryed import the package in my plugin folder with this config of my composer.json : "extra": { "installer-paths": { "web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin"], "web/app/plugins/{$name}/": ["type:wordpress-plugin"], "web/app/plugins/carbon-fields/": ["htmlburger/carbon-fields"], "web/app/themes/{$name}/": ["type:wordpress-theme"] }, "wordpress-install-dir": "web/wp", "dropin-paths": { "web/app/languages/": ["vendor:koodimonni-language"], "web/app/plugins/": ["vendor:koodimonni-plugin-language"], "web/app/plugins/carbon-fields/": ["vendor:htmlburger"], "web/app/themes/": ["vendor:koodimonni-theme-language"] }
It's working for something : The plugin is downloaded in my plugin folder, that is good but it is downloaded in vendor too (dropin-paths make a copy). Just that is not a problem but the plugin in vendor folder is autoloaded and that block my site (error 500, white page)
I have the same problem, the autoloader gets kicked in and gives a Fatal Error on line 13 of carbon-fields/carbon-fields.php when asking for trailingslashit()
I made a fork removing the Autoloader and changed the package type to "wordpress-plugin": https://github.com/fgilio/carbon-fields/commit/4259a1deae4af20c86f1efd67f166fca56570a6e It is working, but theres no Autoloader
Yes @fgilio, it's working, thanks you.
Your welcome @pgrmCreate :) I didn't make a PR because that removes the Autoloader. I don't need it for my use case, but of course it has a purpose.
@fgilio I found a other issue for ajust the problem : i config my json with that : require { "wpackagist-plugin/carbon-fields": "*" }
and with that : "installer-paths": { "web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin"], "web/app/plugins/{$name}/": ["type:wordpress-plugin"], "web/app/themes/{$name}/": ["type:wordpress-theme"] },
The plugin is download directly in plugin folder and not in vendor (with not autoload :))
Oh, I forgot about wpackagist. Awesome!
It would be nice to add this in the readme. Something like:
You can use https://wpackagist.org/search?q=carbon-fields if you need Roots Bedrock compatibility
Thanks guys, good points there.
So, to conclude, you have 2 options to use Carbon Fields with Bedrock and similar environments:
"wpackagist-plugin/carbon-fields": "dev-trunk"
. Once we release the new version, it will be recommended to use that version instead of dev-trunk
. Note: If you've used "wpackagist-plugin/carbon-fields": "dev-trunk"
already, you'll have to call composer clear-cache
before installing, in order to get the latest trunk version.Feel free to reopen the issue if you have further questions.
the problem seam to be again the same with bedrock... Not working with fresh install of bedrock... it seem that carbon field try to load css and js files in a "dist" folder but this "dist" folder doesn't exist in carbon-field directory !
(i've read this page [https://carbonfields.net/docs/guides-bedrock-support-2/?crb_version=2-2-0] but not solving anything)
Good morning,
I have a problem with this torque of technologies. I use bedrock with sage theme of wproot. When i download Carbon fields via composer, i have a error 500 on my website after composer update.
In my log apache i have this : [Wed Mar 02 10:05:07.170780 2016] [:error] [pid 6110] [client 127.0.0.1:33616] PHP Fatal error: Call to undefined function Carbon_Fields\untrailingslashit() in /home/jb/projets/aljt/vendor/htmlburger/carbon-fields/carbon-fields.php on line 11
Bedrock create this structure of project :
All functions of wordpress is not detected in vendor > htmlburger > carbon-fields > ...
Have you got idea for check this problem ?