Publish And Generate Assets In Console Command

Hi All,

I build my site with some less files inside and also with some of another assets, I use hps://github.com/zsoltlengyelit/LessCSS-for-Yii for compile less files, and hps://github.com/andremetzen/yii-s3assetmanager for deploy to S3.

But the problem is when I refresh the assets and want to generate the new one it takes so long until my server stop because its already reach max execution time for compiling the CSS, and I’ve got a better idea to generate all this assets and publish it with console so I could run it when I deploy to production. But another problem is comes up, I couldn’t run :




Yii::app()->getAssetManager()->publish();



it always said :




CConsoleApplication.clientScript is not defined



Is there any chance/way to publish assets with commands/console? I hope this make sense for you.

Thanks.

same idea came to my mind using console to pre-publish assets, however, console app is actually different from webapp, i did not figure out how i would actual do it. so this is still a question mark to me.

i have to admit i never use LESS, but i’m not sure if i like the idea to have LESS to CSS at runtime, here is what i found: this

still use CSS as normal, just CSS comes from pre-compiled LESS

Yeap I still trying to make this happen, get CClientScript working with console but it always be dead end… maybe anyone already trying something and got some tweak or something that would make this happen.

But if I still didn’t found something to solved this maybe I will take your advice to compile the less before deploy it, but I still think it’ll be great if we can publish and generate less with console before we deploy it to production server.

I’ve run across this problem when i wrote my package compressor extension. But you can make it work with some extra configuration in your console.php. See the notes here: https://github.com/mikehaertl/packagecompressor#command-line-maintenance

thx, @mike, bookmarked, will study

Great… Thanks Mike.

I just follow your extra configuration at my console.php especially "assetManager" component and now I can publish my assets from console.

Thanks guys.

Hi TheBee, I am trying to accomplish the same but without any luck.

Followed all indication from Make and your suggestion but not working, when calling getAssetManager throw exception CConsoleApplication and its behaviours do not have a method or closure named "getAssetManager";.

would you mind to share the assets republishing command and if possible console configuration would be helpfull.

Thanks in advance for any help…

Regards

Nestor

As you can see in this link https://github.com/mikehaertl/packagecompressor#command-line-maintenance, you must add assetManager component in console.php.

Yes I followed all that, and first getAssetManager fails as didn’t get autoloaded.

However I solved with Yii:app()->getComponent(‘assetManager’) but then the publish method now it has 1 mandatory parameter that it look like the basePath that it is already configured in console.php, anyway I added with a getBasePath and now looks like it start generating but only 1 directory created and recursively same dir name so many time.

That is way I asked if you have the command code.

Thanks for prompted response.

regards