Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nhayder's avatar
Level 13

how to run npm run production from model class

i'm working on automatic app upgrader class where i can automatically download/unzip upgrade files.

my code is working just fine and things are looking good apart from compiling assets.

basically i need to run this programmatically from a model class after setting up the upgraded files on customer hosting account?

So typically i can manually run

npm run production

My question is how to run NPM commands directly from a model class???

is that possible ???

any recommendations ????

0 likes
2 replies
Braunson's avatar
Braunson
Best Answer
Level 18

While not ideal, you can use exec to execute the command.

1 like
nhayder's avatar
Level 13

thank you braunson, i'm already experimenting with exec command right now.

Please or to participate in this conversation.