-
-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolving location of assets. #183
Comments
Unfortunately, you must stated in the documentation to install the plugin in mode Regarding the resolution of assets, I have already develop this feature:
The library using Assetic and including many helpers for Twig. |
For me it's unclear how fxp/require-asset actually assists in finding the asset directory; in the docs I see stuff like this:
Which basically means I still have to know.. |
It's the bundle that generate automatically the config (see the compiler pass and particularly ComposerAssetsPass). I have not developed this feature for the library because it is already present for Symfony. But you can do a PR for that. |
Ah okay, so basically the And your bundle does this via the container:
Would it not be better to just use the autoloader class as an "anchor"?
That will always work regardless of "parent" framework. And then we could use that to get This would also remove the need for custom configuration when using a non-standard composer path! |
Yes, we can use the reflection of |
Yes, that would be great for non-symfony users :)
So basically this would add about 2ms to page load times. |
I think I will create an independent library for resolving the paths and which can be integrated in any project. |
Okay great, I don't think it needs to be much of a library though ^^ Probably something like the Anyway, thanks for the prompt responses! Let me know if you need more input. |
It's not possible, because the class will not be loaded by the Classloader (plugin installed in global mode:) ). |
I don't mean it must be that exact class, just something like that; simple static class with a few static functions. |
Will you still do that? |
Considering the last comments, is it really useful? |
The comments refer to the global installation, but if there is a separate small footprint library that allows for resolution of asset paths then that library could be included in project-specific composer.json right? |
When creating a library that depends on external assets what is the "recommended" way of doing things?
Ideally the plugin would provide a method that resolves the asset path, since the plugin can always be loaded using the class loader. But if the plugin is installed globally it won't be available inside the project. Alternatively a lightweight composer package could be created that always gets installed by the plugin and has the same resolving logic as the globally installed package.
So maybe the solution is to:
For the resolving package I think having a static helper function is simplest:
Fxp\Composer\AssetPlugin::getNodeAssetPath()
would work fine for most cases.Optionally take an argument like the package name and resolve that to the directory for that specific package.
Ideally if the main project uses some kind of asset manager then it should be possible for the main project to set the base URL for the assets so the library can skip any asset publishing and use the base URL instead. By calling
getNodeAssetUrl()
for example.I'd be up for creating such a lightweight composer package but I'm not sure this is the best approach or if other approaches exist.
The text was updated successfully, but these errors were encountered: