Cannot change any CSS

Hi All

This is my Yii web directory structure:


Under myapp folder there is folder assets.

When I delete this folder, I cannot start Yii application with CException: "CAssetManager.basePath "/www/yii/myapp/assets" is invalid. Please make sure the directory exists and is writable by the Web server process."

So I create this folder. After i run application again some subfolders are created there with some js and css files.

Now I installed JQuerySliderMenu and I want to change some css of the menu. So I edit its css file (for example change font size) but changes are not visible when I refresh page.

In guess this assets directory is writable, because at first I deleted it, after I created it, Yii created the subfolders named like ‘a546eu8d’ and copied queryslidemenu css and js files files inside.

When I open/edit jqueryslidemenu.css from assets folder it is not affected, font_size is not changed.

Any suggestions what am I doing wrong?

As far as I know you are not doing anything wrong and this is a standard assets manager behaviour.

All you have to remember is that you have to delete contents of assets folder (i.e all subfolders, not the folder itself!) each time you do any change in JS or CSS source files (also clean this folder after each framework update to a newer version).

Assets manager works the way that it check if particular folder exits in assets folder. If it does - it is not being recreated, i.e. your changes made to source files are not being propagated. Just ensure you purge contents of assets folder each time you do any change in any of source files of any of widgets, extensions etc. that publishes anything to assets folder and your problem should be solved.

Thanks for quick response.

So what’s the idea of assets in this jqueryslidemenu since I have to delete assets subfolders everytime I change font_size or color?

Sould I the put this css in /myapp/css folder and not use Assets?

The idea is that you are changing JS code or CSS styles inside extension, widget, etc. in development (debugging, testing) stage of you app. In this stage you are purging assets folder with every change to make sure Yii uses the newest version of your CSS or JS files. If you finish with it and go to production stage, you don’t do any more changes to CSS and JS therefore you don’t have to purge assets folder as you don’t have to force Yii to use newest version, because noting changes in this stage.

Depends on approach and what is comfortable for you. CSS files for views (and page layouts) are stored in css folder of your application as it is easy to find and manipulate them there. On the other hand, both JS and CSS files are kept in extension / widget subfolder and published via assetsManager because it is more handy for developers wanting to share their work. You give another user whole subdir containing all PHP code, all CSS styles and all JS code. The last two are published via assets. You point your CSS and JS to what assetsManager produce and you don’t have to bother user to put CSS files to css folder in your app rootdir.

Yes, you can resign using assets, if we are talking only about CSS - you can keep it in css folder as you proposed, if this is handy for you. But things gets changed if you want to use also JS scripts. For the security reasons (this is executable code after all) it should be kept under protected folder, secured with .htaccess folder. And since it is secured, it can’t be accessed by browser and that is why you are using assetsManager - to publish them to assets folder, which is not protected and where browser can easily find those files.

Hope that clears thing a bit. Also - do extensive forum search (and maybe Cookbook) for ‘assets’ word - this case was discussed in many post and reading through them will probable get things even more clear than they are now.


I got the same problem, I wanted to change my CSS for some Yii widget. I tried deleting the subfolders in my assets folder after I edited my CSS in extensions/widget/source/css, problem is after i did so, the widget seems not working. Help anyone?

As far as I know, that is quite impossible. Assets folder is not sensitive for deleting anything inside it. If Yii finds folder, it requires missing there, it will simple recreate it. Problems might arise if it is unable to do so for example due to incorrect folder permission settings. But you would see error saying this in that situation.

I’m 99,99% sure that deleting contents of assets folder in not related in any way to your widget not working any more. I think this is just coincidence and the problem lies somewhere else.