Yii Framework Forum: Publish And Generate Assets In Console Command - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Publish And Generate Assets In Console Command Rate Topic: -----

#1 User is offline   TheBee 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 31-July 12
  • Location:Indonesia

Posted 08 February 2013 - 11:40 AM

Hi All,

I build my site with some less files inside and also with some of another assets, I use h**ps://github.com/zsoltlengyelit/LessCSS-for-Yii for compile less files, and h**ps://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.
0

#2 User is offline   rootbear 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 222
  • Joined: 17-June 11

Posted 08 February 2013 - 01:00 PM

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
I enjoy the Yii.sy coding life here.
0

#3 User is offline   TheBee 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 31-July 12
  • Location:Indonesia

Posted 10 February 2013 - 03:06 AM

View Postrootbear, on 08 February 2013 - 01:00 PM, said:

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.
0

#4 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 10 February 2013 - 05:55 AM

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/m...ine-maintenance
1

#5 User is offline   rootbear 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 222
  • Joined: 17-June 11

Posted 15 February 2013 - 05:45 PM

thx, @mike, bookmarked, will study
I enjoy the Yii.sy coding life here.
0

#6 User is offline   TheBee 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 31-July 12
  • Location:Indonesia

Posted 17 February 2013 - 01:03 AM

View PostMike, on 10 February 2013 - 05:55 AM, said:

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/m...ine-maintenance


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.
0

#7 User is offline   wolfium 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 26-November 14

Posted 26 November 2014 - 11:18 PM

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
0

#8 User is offline   TheBee 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 31-July 12
  • Location:Indonesia

Posted 26 November 2014 - 11:36 PM

View Postwolfium, on 26 November 2014 - 11:18 PM, said:

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/m...ine-maintenance, you must add assetManager component in console.php.
0

#9 User is offline   wolfium 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 26-November 14

Posted 26 November 2014 - 11:41 PM

View PostTheBee, on 26 November 2014 - 11:36 PM, said:

As you can see in this link h++ps://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
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users