I expect Carbon's assets URL-s to be like: http://mysite.dev/wp-content/plugins/my-plugin/vendor/htmlburger/carbon-fields/assets/dist/{asset_name}
Paths URL are like: http://mysite.dev/dist/{asset_name}
Doesn't matter
I'm developing a WordPress plugin
~/htdocs/wordpress/~/htdocs/my-plugin/ln -s ~/htdocs/my-plugin/ ~/htdocs/wordpress/wp-content/plugins/my-pluginCarbon_Fields::directory_to_url() method is not able to deal with symlinked directories.I know that this is not the most popular setup ;) ... but still, it looks like a bug that can potentially cause some issues on more standard setups.
Hi @wujekbogdan and thank you for the report!
If you need a workaround, you can define the Carbon_Fields\URL constant before including autoload.php which should resolve the issue for you.
For themes, I'm using define('Carbon_Fields\URL', get_template_directory_uri() . '/vendor/htmlburger/carbon-fields'); as the workaround.
I have the same problem.
Thanks, it helped.
My vendor folder is outside the document_root, as I don'' want to allow direct web access to my dependencies. It seems that it is not possible to use Carbon Fields in this setup (without changing server configuration), as it requires the web server to be able to resolve URLs to files inside the vendor folder.
My
vendorfolder is outside thedocument_root, as I don'' want to allow direct web access to my dependencies. It seems that it is not possible to use Carbon Fields in this setup (without changing server configuration), as it requires the web server to be able to resolve URLs to files inside the vendor folder.
I'm in the same situation. Only solution I could come up with was to define Carbon_FieldsURL and configure a server redirect specifically for the carbon fields directory. Hacky.
@luishdz1010 @peteshilling haven't tested if this works in 3.0 as well but here is how it can be done in 2.2:
https://carbonfields.net/docs/guides-bedrock-support-2/?crb_version=2-2-0
@atanas-angelov-dev Thanks! The custom directory installer plugin did the trick.
{
"require": {
"mnsami/composer-custom-directory-installer": "1.1.*",
"htmlburger/carbon-fields": "3.0.2",
"htmlburger/carbon-fields-plugin": "3.0.2"
},
"extra": {
"installer-paths": {
"./public/wp-content/plugins/{$name}/": ["type:wordpress-plugin"],
"./public/wp-content/plugins/carbon-fields/": ["htmlburger/carbon-fields"]
}
}
}
Does the above tweak still works (using composer/installers)?
According to https://getcomposer.org/doc/faqs/how-do-i-install-a-package-to-a-custom-path-for-my-framework.md: You cannot use this to change the path of any package. This is only applicable to packages that require composer/installers and use a custom type that it handles..
I tried;
"web/app/plugins/{$name}/": ["type:wordpress-plugin", "htmlburger/carbon-fields"]"web/app/plugins/carbon-fields/": ["htmlburger/carbon-fields"]Does the above tweak still works (using
composer/installers)?
According to https://getcomposer.org/doc/faqs/how-do-i-install-a-package-to-a-custom-path-for-my-framework.md:You cannot use this to change the path of any package. This is only applicable to packages that require composer/installers and use a custom type that it handles..I tried;
- ` "web/app/plugins/{$name}/": ["type:wordpress-plugin", "htmlburger/carbon-fields"]
and"web/app/plugins/carbon-fields/": ["htmlburger/carbon-fields"]
without success.
"extra": {
"installer-paths": {
"./web/wp-content/plugins/carbon-fields/": [
"htmlburger/carbon-fields"
]
}
}
works for me
Does the above tweak still works (using
composer/installers)?
According to https://getcomposer.org/doc/faqs/how-do-i-install-a-package-to-a-custom-path-for-my-framework.md:You cannot use this to change the path of any package. This is only applicable to packages that require composer/installers and use a custom type that it handles..I tried;
"web/app/plugins/{$name}/": ["type:wordpress-plugin", "htmlburger/carbon-fields"]
and"web/app/plugins/carbon-fields/": ["htmlburger/carbon-fields"]
without success.
Make sure to require mnsami/composer-custom-directory-installer
Most helpful comment
For themes, I'm using
define('Carbon_Fields\URL', get_template_directory_uri() . '/vendor/htmlburger/carbon-fields');as the workaround.