Using the Gaufrette Stream Wrap with AsseticBundle

I am trying to use the Gaufrette Stream Wrapper to tell the AsseticBundle where to upload project assets, but I cannot recognize it.

This is what the knp_gaufrette section of my config_dev.yml looks like:

knp_gaufrette: adapters: dev_adapter: local: directory: /vagrant/test create: true filesystems: dev_adapter: adapter: dev_adapter stream_wrapper: ~ 

I checked the wrapper with a simple action to make sure it is registered correctly and it works fine:

 public function thanksAction() { file_put_contents('gaufrette://dev_adapter/test.txt', "ABC\n", FILE_APPEND); return new Response(file_get_contents('gaufrette://dev_adapter/test.txt')); } 

Then I set up an asset bundle configuration similar to this (in config_dev.yml too):

 assetic: read_from: gaufrette://dev_adapter write_to: gaufrette://dev_adapter 

However, when I try to dump assets using console assetic:dump --env=dev , I get this error:

 Dumping all dev assets. Debug mode is on. 10:53:28 [dir+] gaufrette://dev_adapter/css [RuntimeException] Unable to create directory gaufrette://dev_adapter/css assetic:dump [--watch] [--force] [--period="..."] [write_to] 

Additional Information:

symfony / symfony: 2.5.0
symfony / assetic-bundle: 2.3.0
knplabs / knp-gaufrette-bundle: 0.1.7

+8
php symfony assetic gaufrette
source share
1 answer

I had the same issue with Amazon S3 stream wrapper.

My final decision was to comment on the call to mkdir() and check its return value for Assetic DumpCommand.

 private function doDump(AssetInterface $asset, OutputInterface $stdout) { // ... //if (false === @mkdir($dir, 0777, true)) { // throw new \RuntimeException('Unable to create directory '.$dir); //} // ... } 

If you use the dependency manager, copy the command to a new class of commands, comment out the necessary lines.

I think that any directories / resources that do not exist in the path are automatically created.

Example: A directory has an assets folder that is empty. Pressing s3://bucket-name/assets/css/style.css will create the css and style.css .

0
source share

All Articles