Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy images to web folder with assetic

I can't believe that I'm not able to google this...

So, I have a symfony2 application, and I installed jQuery UI with Composer. That means i have project structure like this:

/app/
/src/
/vendor/components/jqueryui/
/web/

I have assetic set up to copy js/css files from the vendor folder to web. That works fine. Config:

assetic:
    assets:
        javascripts:
            inputs:
                - %kernel.root_dir%/../vendor/components/jquery/jquery.js
                - %kernel.root_dir%/../vendor/components/jqueryui/ui/jquery-ui.js
                - %kernel.root_dir%/../vendor/components/jqueryui/ui/i18n/jquery.ui.datepicker-cs.js
        stylesheets:
            inputs:
                - %kernel.root_dir%/../vendor/components/jqueryui/themes/redmond/jquery-ui.css
            filters: cssrewrite

After assetic:dump i have

/web/js
/web/css

cssrewrite rewrites images/image.png to ../images/image.png. I guess that's ok, assumes a /web/images directory with said images.

Now the question is: How do I copy the images from /vendor/components/jqueryui/themes/redmond/images to /web/images?

Or is there another best practice to do that? Excuse me if it's and obvious thing, I'm a .NET guy, just trying out PHP.

like image 876
Necros Avatar asked Dec 13 '13 18:12

Necros


1 Answers

My answer probably isn't spot-on because I haven't tried this with vendor files but this is what worked for me:

app/console assets:install

It copies all of your public resources to your web directory.

This answer by user1814739 helped me understand this and may provide additional information for you.

Also consider this advice from the Symfony Blog:

Although developers usually execute the command without any option, most of the time it's better to execute it with the --symlink option. This makes a symbolic link of your assets instead of actually copying their files. This means that any change in the content of the web assets will have immediate effect in the application.

like image 92
Andrej Stieben Avatar answered Oct 17 '22 12:10

Andrej Stieben