Moving assets to another folder

I am bundling my build-by-Yii Web application with Server2Go into a CD. Now the problem is CD is a read-only media, while Server2Go need to write assets. I can disable Yii to logging so it won’t write to runtime directory. But I don’t know how to prevent it from writing into assets folder. My first thought is, I will just running the application first (so it generated all the files needed) and then burn to cd…

but unfortunately Yii still generates error. Is there anyway to make Yii web application run on CD?

You should avoud any asset to be generate, wich include avoiud to use zii widget.

Theoretically is possible, buy you have to renounce to a lot of framewroks feature.

You need to look into what means Server2Go uses as temporary storage.

It’s probably a loopback device in memory.

Set the Yii asset directory to whatever it is.

@zac

It is quite impossible for not using any widget. My current solution is to tell the user to copy the program to the computer in order to use it.

@jacmoe

I don’t quite get about “set the Yii asset directory to whatever it is”. Mind to explain?

He meant: "set it to whatever the temporary storage folder of Server2Go is". So first you need to find out, wether Server2Go has such a folder and how to configure it.

Check here - http://www.server2go-web.de/wiki/environmentvariables

There is the S2G_TEMP_FOLDER variable that points to the temporary folder where Server2Go can write… so you just need to set the assets folder to it…

@mdomba:

I guess, this is not a web accessible folder but only a directory for internal temporary data.

@junxiong:

You’ll probably need to do much more hacking before you get this to work.

I haven’t tried it… but as it says there those variables are to be used by PHP so it’s worth to try…

Still don’t think it’s accessible - there’s no information what the URL for that folder would be. What you could do, is to map a subfolder of that temporary path to the ‘/assets’ URL. You need to change the httpd.conf in that case:




Alias /assets "/path/to/tmp/dir'"



And configure the basePath of the assetManager component to the same directory.

Yeah… I guess, this must hack both in Server2Go and Yii itself…

But have you tried it…

As I wrote above… it’s worth trying…

I just downloaded Server2Go and changed the "assets" and "runtime" folders to the variable as per documentation… and deleted them from the application structure…

I run it locally on hard disk (haven’t burned it on CD)… but all assets and runtime data was saved in the temporary folder pointed by that environment variable…

Update: I burned a CD with a Yii application… and it works! :D

mdomba, i’m confused now: How can you access the published content in the assets folder via URL then? Don’t you at least have to configure the baseUrl of the asset manager?

Mind sharing your config … ? (BTW i find it strange, that i have to ask you this ;) )

Check my post #11 I wrote that I changed the "assets" and "runtime" folder to the server2go variable…

Here is the interesting part of the config:




return array(

	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',

	'name'=>'My Web Application',

	'runtimePath'=>$_ENV['S2G_TEMP_FOLDER'],

   ...

	// application components

	'components'=>array(

		'assetManager'=>array(

			'basePath'=>$_ENV['S2G_TEMP_FOLDER'],

		),

   ...



Still confused. How is this supposed to work? Let’s say tmp folder is just “/tmp” and a script publishes “button.gif”. So you’ll end up with




/tmp/xyz123/button.gif



But the URL to the published image will look like:




/assets/xyz123/button.gif



How’s tho browser supposed to get access to this published image, if you don’t even set the baseUrl? Not to mention, you didn’t map the tmp folder into the public web directory.

You’re right (as always :P )…

I just assumed that Server2Go will map this… and did not check it…

The button.gif is published in the temp folder (eg c:\temp\button.gif)… and the script does include it as src="c:\temp\button.gif", but this does not work…

I didn’t notice this as the example application I tried was including all from the subfolders … but as soon as there is an CActiveForm with the ajaxvalidation enabled it does not work because it cannot include the activeform.js file…

… and i thought i was getting old ;)

But i think, this could lead to a solution. I would try this:

  • Add a line in index.php to check for / create "/path/to/tmp/assets"

  • Update httpd.conf and add the Alias mentioned above, to map the URL "/assets" to directory "/path/to/tmp/assets"

  • Configure basePath to "/path/to/tmp/assets" like you already did