Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why asset:install doesn´t copy /Resources/public to /web folder?

I'm having an issue running php app/console asset:install command. My OS is Windows.

My intention is to copy the css, js, images, etc, files from app/Resources/public by using that command. After I run the command, a bundles folder is created in /web. But in the created bundles folder there aren't any of the files from app/Resources/public. Only two folders: sensiodistribution and framework.

Why don't I get my AppBundle folder with the copied assets in /web/bundles?

like image 655
nestor Avatar asked Sep 14 '25 15:09

nestor


2 Answers

Your Resource > public folder must be under you bundle or application not under your app folder, you can add twig files to app/resource folder to override (default) files like we do it to override error page, but not for assets, i tried it didn't work.

like this

then it will work, you can check this here - link

and it will be better if you use symlink instead of coping folders / files

php app/console assets:install --symlink
like image 163
Nikhil Malik Avatar answered Sep 17 '25 05:09

Nikhil Malik


app/console assets:install only installs assets that are found in bundles. app/Resources is not considered a bundle, so those assets are not being installed.

The Official Symfony Best Practices actually recommend to store public assets (such as CSS stylesheets, JavaScript files, images, etc.) directly in the web/ directory. As you can see on that page, this also makes it easier to use the assets in your templates.

The purpose of the app/console assets:install command is to copy or symlink assets, that are downloaded to your vendor/ directory as part of third-party bundles, to your public web/ directory. A good example is the debug toolbar.

However, your own assets are already part of your project, so you can just as easily store them directly in the web/ directory. There is no benefit in storing them in the app/Resources directory in order to copy them to web/ in a seperate step.

Of course, if you have source files (such as SCSS files or un-minified CSS/JS files), you might not want to store them in a public directory. In that case, use app/Resources to store the source files and use a build tool such as Assetic to copy the minified / processed assets to the web/ directory.

like image 33
Nic Wortel Avatar answered Sep 17 '25 05:09

Nic Wortel