Open ghost opened 10 years ago
I think this command sp:bower:install could be used to prepare a server and without the obligation to reload it after each deploy.
So to have a different cache than symfony seem to me a good idea. As i can commit the spbower cache and leave the symfony cache clear. All my server don't have php and nodejs installed together (a security hole for now : debian having not yet a prod version of nodejs)
@jrobeson Or maybe are you right with this another solution :
Even without cache the bundle should give js and css corresponding only to package name.
The cache from bower has nothing to do with the cache from this bundle. The cache from this bundle is used to store the mapping received from bower list --json
, so it is not necessary to always execute this command when a registered asset is called.
i know that, but i mean specifying the cache in the .bowerrc so bower won't try to write a cache in an unwriteable directory
I agree. Every now and then I get the message: InvalidArgumentException: The directory "/foo/BarBundle/Resources/config/bower/../../public/components/cache" is not writable.
This cache folder should not be in my bundle directory structure but rather somewhere in app/cache.
@xatoo You can already do that
sp_bower:
bundles:
FooBundle:
cache: /path/do/different/cache-dir
The cache @jrobeson describes is the one from bower itself and has nothing to do with the cache you want to change :)
@Spea Ow, that is awesome! Sorry for the confusion.
@Spea : regarding your last response: but why is the default to ever write there?
There were some errors when using the app/cache directory for this cache. Also it was kinda slow to recreate the asset-cache on every cache:warmup, thats why I decided to use another directory as the default one, but you can still change it ;)
So i understand better as the cache works.
Event that, I have yet a problem with the actual cache :
Recreated the sp cache, demand bower list --json
to be callable, and as the spcache store the absolute path, it seems to me that it is not possible to send it to a server without node.js installed.
I will try to change this behaviour.
What is the correct way to provide custom cache service? In order to fix our issue described in #123 I wanted to set service for cache:
sp_bower:
bundles:
OurBundle:
cache:
id: our_bundle.cache.bower_dependencies
our_bundle.cache.bower_dependencies:
class: BPO\OurBundle\Service\Cache\BowerDependenciesCache
arguments: [ "%kernel.cache_dir%/../bower_dependencies", ".sp_bower.data" ]
I always get exception:
[RuntimeException]
Cache service with id [our_bundle.cache.bower_dependencies] not found
When I dump available services ($container->getDefinitions()
) in Sp\BowerBundle\DependencyInjection\SpBowerExtension::createCache()
I get:
array(9) {
[0]=>
string(25) "sp_bower.filesystem_cache"
[1]=>
string(32) "sp_bower.dependency_cache_warmer"
[2]=>
string(22) "sp_bower.exec_listener"
[3]=>
string(30) "sp_bower.cache_create_listener"
[4]=>
string(14) "sp_bower.bower"
[5]=>
string(22) "sp_bower.bower_manager"
[6]=>
string(32) "sp_bower.package_naming_strategy"
[7]=>
string(30) "sp_bower.assetic.config_loader"
[8]=>
string(31) "sp_bower.assetic.bower_resource"
}
So it's impossible to use custom (external) service?
I tried using the default app/cache/(dev|env)
folder, but it gets cleared on every app/console cache:clear
, as @Spea mentioned.
So, I figured why not use something like app/cache/bower/(dev|env)
, since app/cache
is already writeable and app/cache/bower
does not get cleared automatically.
sp_bower:
bundles:
AppBundle:
cache: %kernel.cache_dir%/../bower/%kernel.environment%
Could there be any downsides to this that I am unaware of?
Thanks!
@liviucmg that's actually a really good idea! +1
actually i discovered that @liviucmg is a very problematic solution, since the cache should not be created for every environment. this is the best solution that i found:
sp_bower:
bundles:
AppBundle:
cache: %kernel.cache_dir%/../bower
during the bower installation phase it creates a cache directory here:
/path/to/bundles/AcmeBundle/Resources/config/bower/../../public/components/cache
I don't think it should attempt to write anywhere except the symfony cache and the target asset location.
It is possible to configure these directories via this entry in a
.bowerrc
:as per this stackoverflow post: http://stackoverflow.com/questions/17881116/how-to-change-bower-default-cache-git-templates-completion-folder-locations/18564317#18564317
or this with the bower command itself:
although there could be some problems with that as per this bower issue: https://github.com/bower/bower/issues/1043 if the build system is not connected to the internet.
This is my first time using bower, so my assessment of how to solve this problem could be incorrect.