Symfony applications on CD-ROM

Posted by thaberkern on Dec 18 2007 | Symfony

The last week I coded a webbased application thats being used directly from CD-ROM. I used Server2Go as a CD-ROM Webserver that servers the application for browsing and searching on the CD-ROM.As you know my favorite Webframework is Symfony (www.symfony-project.com) so i developed this piece of software with the most current stable symfony version (1.0.9).

There are only some things that needs your attention if you want to make a symfony application runnable from CD-ROM:

1.) Freeze it: After developing you have to freeze your project with:symfony freeze app-name

2.) Now copy the entire (freezed) project folder to the htdocs folder of your Server2Go directory

3.) Clear the cache folder! You can do this by manually delete the content of this folder or by using “symfony cc” before copying the data to the htdocs folder

4.) Open the server/config_tpl/httpd.conf file and change the root directory of the server to the web folder in htdocs:

DocumentRoot “%CDPMS:DOCROOT%/web”

<Directory “%CDPMS:DOCROOT%/web”>

</Directory>

So far so good. Now the tricky part begins. Symfony is caching a lot of files and data in order to provide the best possible performance. Therefor views, configfiles and so on will be cached. Where’s the problem? The problem ist that the cache folder on CD-ROM isn’t writable and symfony is throwing exceptions if it can’t write the cache data…

My first thought: No problem, you have just to deactivate the caching in the settings.yml via

cache: off

Works great for view data, but not for the cached config data. Symfony always caches the config, there is no way to deactivate this (or i didn’t find one). So what to do? Was symfony the wrong choice for a cd-rom webapplication? No of course not ;)

There possibility to customize the project structure (foldernames and hierarchie) via the constants.php file. You will find this in the htdocs/data/symfony/config folder. Open it and look for the line that starts with ’sf_cache_dir’ and change it to:

’sf_cache_dir’ => $sf_cache_dir = $_ENV[’S2G_TEMP_FOLDER’].DIRECTORY_SEPARATOR. “cache”. DIRECTORY_SEPARATOR. $sf_environment,

Thats it! This line redirects the cache folder to a temorary folder on the users machine (is done by the S2G_TEMP_FOLDER environment variable that is set by Server2Go.

After that you can burn the Server2Go folder to a CD-ROM and everything works as expected

Book Mark it->del.icio.us | Reddit | Slashdot | Digg | Facebook | Technorati | Google | StumbleUpon | Windows Live | Tailrank | Furl | Netscape | Yahoo | BlinkList

7 comments for now

7 Responses to “Symfony applications on CD-ROM”

  1. Gerald

    thanks for the tips, I never thought it would be possible, sounds really great, I’ll probably use it in the future.
    You did not mention it but I guess it also support MySQL database?

    19 Dec 2007 at 09:24

  2. Interesting stuff. Did you use a database? Any trouble with that?

    19 Dec 2007 at 11:37

  3. thaberkern

    Hi,

    the project doesn’t use MySQL but is is possible to use MySQL from CD-ROM with Server2Go. Should be nor problem to access with symfony

    Timo

    19 Dec 2007 at 13:30

  4. grayblur

    maybe we could use SQLite ,then run in memory mode..

    is that possible?

    20 Dec 2007 at 12:17

  5. thaberkern

    Yes SQLite is alos supported by Server2Go ;) In this case you doesn’t need a MySQL-Server anymore.

    20 Dec 2007 at 13:28

  6. […] Symfony applications on CD-ROM […]

    24 Dec 2007 at 03:13

  7. […] Symfony applications on CD-ROM […]

    30 Dec 2007 at 21:50

Trackback URI | Comments RSS

Leave a Reply