PHP does not parse any js files, so you cannot use Yii there. It would be possible to render a js file as result from a Yii action (e.g. let a Yii URL rule match "myscript.js" and write a controller action that outputs js) , but i would not consider this a clean approach. Instead you should try to write generic javascript code (easy to compress and cacheable on clientside) and make the dynamic parts configurable through some inline script block in your Yii generated HTML.