Symfony-Zone | Timo Haberkern blogs about symfony

Dec/07

18

Symfony applications on CD-ROM

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

· · ·

13 comments

  • Gerald · 19. December 2007 at 09:24

    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?

  • Mike Nolan · 19. December 2007 at 11:37

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

  • Admin comment by thaberkern · 19. December 2007 at 13:30

    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

  • grayblur · 20. December 2007 at 12:17

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

    is that possible?

  • Admin comment by thaberkern · 20. December 2007 at 13:28

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

  • rpsblog.com » A week of symfony #51 (17-&gt;23 december 2007) · 24. December 2007 at 03:13

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

  • Symfony.es » Blog Archive » Una semana con Symfony #24 (17->23 diciembre 2007) · 30. December 2007 at 21:50

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

  • Massimiliano · 17. October 2008 at 16:37

    You can use this trick with symfony 1.1: edit your config/ProJectConfiguration.class.php and add these lines in the setup method:

    $this->setLogDir($_ENV['S2G_TEMP_FOLDER'] . ‘/log’);
    $this->setCacheDir($_ENV['S2G_TEMP_FOLDER'] . ‘/cache’);

  • Lajuana · 28. October 2008 at 18:21

    Keep up the good work.

  • hammudi · 10. November 2008 at 08:50

    i’ve a plan to build an Inventory System using Symfony, is it possible to “secure” the code… so others can’t modify my application? and even copy it?
    thx…

  • hendra1 · 26. August 2009 at 04:26

    hello your articel is very nice…
    i just want to know where is the “constants.php ” file
    if i’m using symfony 1.2 ?

    thanks before…

  • Admin comment by thaberkern · 26. August 2009 at 07:57

    Seems that I need to update the article :-) You are right. In Symfony 1.2 there is no constants.php any more. You will have to set the path via sfConfig::set(…) in the config/PojectConfiguration.class.php. I will write a post about this as soon as possible

    Timo

  • hendra1 · 28. September 2009 at 04:56

    @thaberkern

    hello thaberkern, i try to figure it out how to change the cache directory in symony 1.2, but it’s not as simple like in symfony 1.0

    i try to following your advice to set via config in ‘config/PojectConfiguration.class.php’ but nothing happen. The cache is still in root directory, i’ll try to set config in action.class, the cache is move out to my cache directory.
    But the problem is not all the cache file is move out..

    have you find the solution..?

Leave a Reply

<<

Theme Design by devolux.nh2.me