Hi there,
Does anyone knows about Yii class that would be a wrapper for basic PHP file open routines, like fopen? I know CFileHelper, but it hasn’t got any function for opening a file directly stored on server.
Why would I need that, someone might ask? Well, I’m using: Yii::app()->clientScript->registerScriptFile() after Yii::app()->assetManager->publish() to include JavaScript file and be able to use it within a page.
But what about situation, when I have to actually change something inside JS file? For example: insert actual path to image files, it uses. If I would use it on static webpage, I would do one time edit of JS file and problem would be gone. But I’m using it in dynamic environment of Yii and I have no idea where file will be put by Yii after Yii::app()->assetManager->publish().
Well… I can publish files to assets folder from source but change permanently JS file by entering there paths pointing to source folder from where assetsManager publishes them. This might sound as some kind of idea. But what if files will be put on another server in another path/directory? Remember each time that I have to manually update paths in JS file?
I’m thinking about publishing all files that are needed via Yii::app()->assetManager->publish() except JS file I need to modify. Then open that file directly from source folder to a string, modify what I need (i.e. paths) and put to website with Yii::app()->clientScript->registerScript this time.
If anyone knows a better way to achieve it, I will apperciate any advise.