Symfony2 and Assetics : symlink on Windows 7?
Asked Answered
R

5

8

I'm having a hard time using assetics to load resources in my views (I work with Symfony2). I was working on Linux (Ubuntu 10.4) and switched to Windows 7 a few days ago. I've always been having trouble (some images didn't load for example), but at least most images, and all styles and scripts were loading alright.

When I switched to Windows, some resources weren't loading, so I tried a php app/console assets:install web --symlink

I was quite surprised to see that it had deleted the whole public folder of the bundle I was working on. And there was no way to find the sources again (fortunately, I had saved some of them, and I was able to retrieve most of my work thanks to cached files).

After I've recovered my files (and backed them up), I tried to command again. Same result. I tried without the --symlink and it created some folders in the web/bundle folder, instead of files that were there before (supposedly, the symlinks).

Now the command doesn't even answer anymore (it has been erasing my sources even in some of my backup folders!!).

Bottom-line : is there a way to configure assetics on Windows 7 so that it doesn't eat my files and loads the resources (including images in css) correctly?

Thanks in advance!

Edit :

I just ran the command again and this time it worked (copied the files in web/bundle/...). I must say I don't really understand how or why it worked this time... If by chance anyone knows...

Recording answered 5/6, 2012 at 9:28 Comment(0)
S
5

Symfony2 uses the PHP symlink function, according to the docs it should work for Windows Vista, Server 2008 or greater.

By default only Administrators can create symlinks in Windows. So you'll have to use an elevated prompt or give your user the SeCreateSymbolicLinkPrivilege privilege.

Stiltner answered 5/6, 2012 at 16:56 Comment(2)
That's what I saw, but I was having trouble nevertheless... Well, now it's working so...Recording
It's not working for us on a Windows 7 box with XAMPP and PHP 5.3.8, regardless of the documentation, see #13376819Absinthe
D
25

In order to run assets:install web --symlink on a PC you need an elevated command prompt (fancy word for cmd.exe in Administrator mode).

Dhruv answered 15/1, 2014 at 23:21 Comment(1)
This should be the correct answer, symlinks can only be created with admin privilage I don't understand whyWeston
S
5

Symfony2 uses the PHP symlink function, according to the docs it should work for Windows Vista, Server 2008 or greater.

By default only Administrators can create symlinks in Windows. So you'll have to use an elevated prompt or give your user the SeCreateSymbolicLinkPrivilege privilege.

Stiltner answered 5/6, 2012 at 16:56 Comment(2)
That's what I saw, but I was having trouble nevertheless... Well, now it's working so...Recording
It's not working for us on a Windows 7 box with XAMPP and PHP 5.3.8, regardless of the documentation, see #13376819Absinthe
P
1

You can do it with windows console, but Git Bash is much nicer. Get it and download. Ps. If you never used git before this is the right time to start. :)

When you installed it search in windows programs for git bash and right click it to run as administrator. If you have Git bash opened from the right click in the current folder "git bash here" it wont work because it is not launched by default in administrator mode. If you done this you get this warning.

app/console assets:install web --symlink

enter image description here Warnings. Hard copy where used instead of symlinks.

However if you play nice and do it as i said. (run as administrator.. you will get everything work nice and smooth.

app/console assets:install web --symlink

enter image description here Symlinks where created! :) Now you don't need to assets:install every time you made changes to your css files.

Ps. git bash console is nicer then native windows console but... for example Unix system such as Ubuntu would look even better. Also Symfony on Windows with Xamp will run much slower than on Linux Ubuntu system. I am talking about 5x to 20x faster page response on Linux.

Pixilated answered 28/1, 2016 at 5:58 Comment(0)
S
0

You can use configure the composer.json and use forever without any problems,puting in it --symlink.Here is how you can do it. http://www.w3docs.com/snippets/symfony/how-to-keep-symlinks-in-web-bundles-after-composer-update.html

Sonorant answered 11/6, 2015 at 20:13 Comment(1)
Please post the answer directly whenever possible, instead of posting a link to the answerVedetta
V
0

You can add this configuration option in your composer.json:

{
    "extra": {
        "symfony-assets-install" : "symlink",
    }
}
Vedetta answered 13/6, 2016 at 13:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.