assets:install creates a wrong path - directory

I have a problem with the assets:install command in Symfony 3. As the manual states,
When executed without options, the command copies into web/ all the files found in the Resources/public/ directories of your application and bundles.
The path to my javascript file is: src/AppBundle/Resources/public/js/script.js
Now, when I run php bin/console assets:install --symlink, it puts the symlinks to web/bundles/app/js/scripts.js.
What I want is to make it create the symlink at web/bundles/AppBundle/js/scripts.js. Any hint is appreciated.

if you look inside web/bundles after running assets:install, you will see that app actually symlinks to src/AppBundle/Resources/public. so web/bundles/app/xxx should be the right convention and pointing the the right place.
web/bundles/AppBundle/xxx is the wrong convention.

Related

Symfony assetic issue file does not exist

I tried to resolve my problem all this morning but I didn't find the solution anywhere.
I have a Symfony project and I use Assetic for my css and js files.
Till today when I ran php bin/console assetic:dump --env=prod, it worked fine.
But now I have this error :
[Symfony\Component\Config\Exception\FileLocatorFileNotFoundException]
The file "C:\wamp\www\PLIE08\app/config/config_=prod.yml" does not exist.
I don't understand why it adds = in my file.
Moreover, after running this command I realized that a folder called "=prod" is created in var/cache in addition to the dev and prod folder.
I tried to update, install composer, clear the cache, look in config file if something was wrong but I'm still blocked...
Somebody can tell me why it searchs the bad file ?
Thanks
try this command bin/console assetic:dump -e prod to verify duplicated =. Otherwise remove the entire content of the cache/prod folder, doest not clear:cache, remove all manually.

symfony2 assets in changed web folder

I'm using Symfony2 in my project and I changed web root ditectory. I followed instructions on this page http://symfony.com/doc/current/cookbook/configuration/override_dir_structure.html. Now my project structure looks like this:
/frontend - the new web root dir
/myproject - the project dir
Then i'm installed and dumped assets
php app/console assets:dump
php app/console assetic:install ../frontend --symlink
Most things works fine. But the problem is that I can't acces to any asset in /bundles directory, Symfony returns error
No route found for "GET /bundles/..."
But I can see my assets in this directory in explorer (symlinks created correctly).
Is your web server configured to follow symlinks? Without knowing which web server you are using, as an example in apache you need to set the FollowSymLinks option. Alternatively, remove the symlink option when doing assets:install.
Also, it's probably just a typo, but you've got the commands for installing assets and dumping assetic a bit muddled in your question - should be something like this:
php app/console assets:install --symlink ../frontend
php app/console assetic:dump -e dev

How to get assetic to update assets in dev enviroment in symfony2?

I have the issue that my assets, e.g. my sass and javascript, did not recompile on file modification. I installed I accessed them via symlink option and access the dev environment via localhost:8000. I have to manually call /app/console assetic:dump for them to update.
How do I get assetic to watch for file modification?
You can also use
php app/console assetic:dump --watch
If you want to watch for file modifications. This will re-run assetic:dump in the background automatically for you.
And yes dont forget if you use dev then access your site via app_dev.php
And small note... when you use production environment then make sure you execute assetic:dump with --env=prod (without --watch as well)
I realized I have to access the dev page with app_dev.php:
localhost:8000/app_dev.php/
Try to execute:
php app/console assetic:dump --env=dev

Url path in Symfony

Need to save data in text file. not able to get the correct text file path. Please suggest.
now, I am trying by using this code $file_url= "{{ asset('/temp_files/calender.txt') }}";
$ourFileHandle = fopen($file_url, 'w') or die("can't open file1");
but not getting the exact path.
Use templating.helper.assets, like so
$this->container->get('templating.helper.assets')->getUrl('bundles/somename/other/calendar.txt')
Where bundles/somename exists in your web/bundles folder. If you don't have anything in your web/bundles folder, then run the following command:
php app/console assets:install ./web --symlink
The other folder listed above will be one your create in the Resources/public folder of your bundle.

symfony2 assets:install output directory

I am trying to change the default "web" directory of symfony to something else for example public_html.
I got most of it working by following the manual here -> http://symfony.com/doc/master/cookbook/configuration/override_dir_structure.html
Very last part of that document explains how to change assetic so that assetic:dump will output to the correct directory, so that works, and the website also works.
However the document doesn't seem to explain how to change the output directory of the assets:install command.
When i run this command it still outputs to the web directory.
Does anybody know how to change this ?
assets:install requires a parameter telling where to install the assets:
app/console assets:install path
Just provide your path instead of web.
You can set a path parameter to assets:install
But I think in some case better not overriding the directory structure, preferably making a symlink to the web dir.

Resources