[symfony-users] Re: Event when configuration (app.yml) has changed? (solution + some remarks about documentation)
Hello Ant, Thanks for your comment. I'd have to write a plugin that is called from every action, or rather I'd have to automatically call the code by injecting a caller into the symfony request bootstrapping chain. Which works fine, I've done that in the past for example for allowing users to switch between languages. But then I'd have to do a stat() or md5() on the .htaccess file on every request, or even worse, I'd actually have to read in the whole .htaccess file on every request to check if it had changed. Reading in a whole file on every request for something that only changes every few months isn't very efficient. Or I'd have to keep my own flag on whether or not the app settings file had changed, which seems brittle. On top of that, it's conceptually not what I want to do: I don't want to check on every request, I want to do it only when the settings changed. Anyway, turns out that the cache:clear event will work for me because in the production environment it needs to be called after changing the app.yml file anyway. It's not 100% correct because in the debug environment the settings from app.yml are updated 'silently' but it's good enough for what I need to do at this moment. I'd still like to ask for a 'a setting has changed' event to be added. One event for project-, app- and module settings should be enough as the user can then check for himself if it concerns a setting he's interested in. Secondly, I'd like to make a comment on the wording in the documentation, specifically the 'extending Symfony' part. The event system is described in these terms: Some of the symfony classes notify an event at various moments of their life. This is if not wrong then at least misleading and not congruent with the terminology that is used with event systems (signals, delegates, ...) in other programming languages. It's not the events that are notified, it's the functions or methods that are registered as the recipients of the notification that are notified. The IMO correct way of phrasing it is Some of the symfony classes emit an event at various moments of their life. 'Events' are 'emitted' or 'send', and that way they 'notify' the 'recipients' or 'slots' (personally I like the naming that is used in libsigc or boost.signals best: a 'signal' 'emits' and in that way calls a 'slot', but I'll admit that 'signal' and 'slot' are not very intuitive names for non native speakers. At least I know that it took / me/ some time to accept the term 'slot') Anyway, in my opinion, if the documentation would be changed to replace 'notify an event' by 'send an event' or 'emit an event', that would be a lot clearer. Then finally, now that I'm typing this anyway ;), I might as well describe what I did to get this to work in case anyone ever finds this in the mailing list archives. I don't think it's common enough to write a wiki entry about, but I thought it was halfway clever so maybe it'll help someone in the future. First, I have a file called .htaccess.tpl in my symfony data directory that looks like this (only the relevant parts with some context - the actual name of the product is replaced with 'MyProductName'): IfModule mod_rewrite.c RewriteEngine On # Redirect all requests to 'downloads/MyProductName*' # to the latest version. RewriteCond %{REQUEST_URI} !^##LASTEST_VERSION_PLACEHOLDER## RewriteCond %{REQUEST_URI} ^/downloads/MyProductName.* RewriteRule ^(.*)$ ##LASTEST_VERSION_PLACEHOLDER## [R=permanent,L] # uncomment the following line, if you are having trouble # getting no_script_name to work #RewriteBase / Then, this is what frontendConfiguration.class.php looks like: ?php function rebuild_htaccess() { $template_path = sfConfig::get('sf_data_dir') . '\.htaccess.tpl'; $output_path = sfConfig::get('sf_web_dir') . '\.htaccess'; $input_h = fopen($template_path, 'r'); $output_h = fopen($output_path, 'wb+'); while ($line = fgets($input_h)) { $line = str_replace('##LASTEST_VERSION_PLACEHOLDER##', sfConfig::get('app_latest_version'), $line); fputs($output_h, $line); } return true; } class frontendConfiguration extends sfApplicationConfiguration { public function configure() { $this-dispatcher-connect('task.cache.clear', 'rebuild_htaccess'); } } Then finally, the frontend's app.yml contains this: all: latest_version: /downloads/MyProductName_1.1.0_setup.exe So now all I have to do when I release a new version of my product, I change the app.yml, call cache:clear and the .htaccess is updated (the setting is used in other places in the frontend well, of course). This technique can be used for other ways of automatically generating other parts of .htaccess too. Ideally I'd move the rebuild_htaccess() function to another location and include() it from frontEndConfiguration.class.php but that's a details that is left as an exercise for the reader :) cheers, roel On Mar 6, 2:50 am, Ant Cunningham prodigital
[symfony-users] Event when configuration (app.yml) has changed?
Hi, I want to put a certain url that is defined in the frontend's app.yml and put it in my .htaccess file., in a RewriteRule (I want to redirect all file downloads that match a certain pattern to the setting from the app.yml - all people who link to an old version of my software installer should be 301 redirected to the latest version). So I made a .htaccess.tpl with a placeholder in the the download location - '##LASTEST_VERSION##' so that I can search and replace in that file and write the result to the .htaccess file. Result: except for the very first request after the change to the app.yml is made, the .htaccess will be up to date. Except for one thing: I can't find a way to be notified of when the app.yml is changed. I could of course regenerate the .htaccess on every request but that seems like a waste and a race condition waiting to happen. So, my question: is there a way to be notified that app.yml has been changed? Is there a class I can subclass? Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Re: PHP 5.2.4 dependency
I found out I had the same problem this weekend. I'm running CentOS 4.7. What I did was to download packages from http://www.smudge-it.co.uk/pub/yum/centos/4/i386/, install them with yum install *rpm (in the directory where I had downloaded the relevant packages) and boom I was good to go. Maybe these people have a yum channel too, I'm not sure and I didn't look. For this to not be a cludge, they would have to be one and your admin would have to use it. On Feb 10, 3:52 pm, bpfar...@gmail.com bpfar...@gmail.com wrote: I'm currently developing an application in sf1.2 (which is awesome, congrats Fabien), but I have to deploy to a centOS machine, which only supports php 5.1.6. I have a few questions: 1) I uploaded my source, and all the pages work except the homepage, which gives a SQLSTATE error. Is it possible to use sf1.2 with php 5.1.6, just without certain features? If so, what might be causing a SQLSTATE error? 2) Is downgrading to sf1.1 my best option for compatibility? 3) My sysadmin is refusing to upgrade to php 5.2.4 because he thinks that there are inherent security flaws in anything that's not in rpm. Is this the case? Should we be concerned about upgrading to php 5.2.4? I'm not sure why we're even using centOS, nothing that we do is mission critical, the sysadmin is pretty paranoid, and obviously uptime is important, but we aren' t handling credit card transactions or anything. Thanks for the help, -Brendan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Re: SymfonyCamp update
Do you have a projection on when the programme for the dev days will be available? I'd like to know what subject wills be discussed before committing 2 days. cheers, roel -Original Message- From: symfony-users@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Stefan Koopmanschap Sent: Wednesday, August 15, 2007 17:00 To: symfony users Subject: [symfony-users] Re: SymfonyCamp update Thierry, Funny enough from The Netherlands I have had the least registrations so far. I've been informed by some contacts that some registrations will follow. As I said earlier, due to privacy reasons I can not disclose this information, however, if any people on this list want to give a shout that they will be here, it's up to them to do so. Sincerely, Stefan On Aug 15, 10:38 am, Thierry [EMAIL PROTECTED] wrote: Which members from Holland are going? Could you maybe publicize the list (give the registered people the option to disclose this info) Would like to know who is working with Symfony. On Aug 14, 4:38 pm, Stefan Koopmanschap [EMAIL PROTECTED] wrote: Hi Darren, I have one other registration from the UK so far (and I think this person is a member here, so if he would like to get in touch with you, he can ;) ). Obviously, for privacy issues, I can not disclose any registration information. Stefan On Aug 14, 1:32 pm, Darren Beale [EMAIL PROTECTED] wrote: Anyway, have a look atwww.symfonycamp.com... I hope to see you there! Very interesting I'm seriously considering it. As a matter of interest are there any other developers from the UK going as I might drive/ferry. db -- Darren Beale 07711 716 197 http://bealers.com-Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] translated strings in yml file
Hi, I have given up on trying to maintain several messages.XX.xml XLIFF files, as they got out of sync very easily (wrt the id numbering) and the i18n-extract task doesn't fix those issues (re-syncing the id's and strings to be translated). Also, having the 'source' string duplicated in every messages.XX.xml file tripped me up a few times. So I wrote a simple pake tast that reads in a messages.yml file and spits out the corresponding XLIFF files. The format is roughly like this: - messages - source: This is the string in the template en:This is the English translation nl: Dutch string here - source: Another string in the template en:This is the English translation of that string nl: Dutch version of it here etc. As you can see, this keeps all languages in the same file, which may or may not be desireable in certain circumstances. Anyway, now to my question: for now I've written this in a separate 'plugin' (it only has this one pake task). Should I merge this into sfI18nExtractPlugin so that we can work towards one great one-stop-solution-for-all-i18n-needs plugin, or should I package and maintain this as a separate plugin? Also, is there any interest for something like this at all? cheers, roel PS on a technical note: does anyone know of a way to pretty-print (indent) xml files generated with php's SimpleXML or do I have to rely on the tidy extension being available in php? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Re: dynamically generating stylesheet
[EMAIL PROTECTED] wrote: 2/ As symfony can add a fake .html extension to action, I think you can handle the .css in the same way, even symfony appends automatically it. See the link below for detail: http://www.symfony-project.com/book/trunk/09-Links-and-the-Routing-System#Adding an .html Extension Hmm I've looked into that a bit but it seems to be only for .html. What if you replace in your template the metas by a partial or a component ? I'm not sure what you mean by this - are you suggesting I should 'hard-core' the css filename into the header? I could do that I guess, but I'd prefer not to. Thanks for your answer. cheers, roel Nautile On 24 mai, 10:32, Roel Vanhout [EMAIL PROTECTED] wrote: Hi, I'd like to generate my stylesheets dynamically (so that I can use variables for colors and use the link_to() helper for image tags in @url's) but I didn't find anything specific about it in the manual. All that is really needed is to run the stylesheet template through the template processor once, but that doesn't seem to be possible. So my fallback idea was to delete the /css directory from my web root, make a module called 'css' and have actions in there for every stylesheet I need (at the moment only one, 'style.css'). I think I would have to include my stylesheet with a link to /css/style and not /css/style.css, but I could not find a way to suppress the '.css' that is added automagically by symfony. Now my actual questions: 1) Is this (i.e., treating stylesheets like all other pages, with an action and a template) the way to have dynamic stylesheets? 2) How do I stop symfony from adding .css to my stylesheet, or will I have to use mod_rewrite to re-route /css/style.css to /css/style? Thanks. cheers, roel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Re: dynamically generating stylesheet
[EMAIL PROTECTED] wrote: Now my actual questions: 1) Is this (i.e., treating stylesheets like all other pages, with an action and a template) the way to have dynamic stylesheets? for small site ok, for big sites a no go for me How would you do it on a big site? How do you handle images in stylesheets, do you just always use absolute url's? In the past (on websites that didn't use symfony) I've used a simple script that would pre-process my stylesheets (link to stylesheet would look like link rel=stylesheet href=/css/serve_css.php?stylesheet=main type=text/css, serve_css.php would then include() main.css and do some variable substitution), maybe I should just upgrade that script a bit and put in just enough symfony include()'s and initialisation code to be able to use the image_tag() helpers without having the overhead of the whole routing / database etc. Or maybe I should setup apache to use php to handle .css files - there would be some overhead (of starting the php processor) but not much compared to using a full symfony request, and it would only be upon each user's first visit to the site, so as a percentage of total processing time it would be a small overhead. Anyway, thanks for your answer. cheers, roel 2) How do I stop symfony from adding .css to my stylesheet, or will I have to use mod_rewrite to re-route /css/style.css to /css/style? U can use a route like /index.php/getmystylesheet.css just use index.php! so the webserver can handle the request mfg tobi On May 24, 10:32 am, Roel Vanhout [EMAIL PROTECTED] wrote: Hi, I'd like to generate my stylesheets dynamically (so that I can use variables for colors and use the link_to() helper for image tags in @url's) but I didn't find anything specific about it in the manual. All that is really needed is to run the stylesheet template through the template processor once, but that doesn't seem to be possible. So my fallback idea was to delete the /css directory from my web root, make a module called 'css' and have actions in there for every stylesheet I need (at the moment only one, 'style.css'). I think I would have to include my stylesheet with a link to /css/style and not /css/style.css, but I could not find a way to suppress the '.css' that is added automagically by symfony. Now my actual questions: 1) Is this (i.e., treating stylesheets like all other pages, with an action and a template) the way to have dynamic stylesheets? 2) How do I stop symfony from adding .css to my stylesheet, or will I have to use mod_rewrite to re-route /css/style.css to /css/style? Thanks. cheers, roel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] dynamically generating stylesheet
Hi, I'd like to generate my stylesheets dynamically (so that I can use variables for colors and use the link_to() helper for image tags in @url's) but I didn't find anything specific about it in the manual. All that is really needed is to run the stylesheet template through the template processor once, but that doesn't seem to be possible. So my fallback idea was to delete the /css directory from my web root, make a module called 'css' and have actions in there for every stylesheet I need (at the moment only one, 'style.css'). I think I would have to include my stylesheet with a link to /css/style and not /css/style.css, but I could not find a way to suppress the '.css' that is added automagically by symfony. Now my actual questions: 1) Is this (i.e., treating stylesheets like all other pages, with an action and a template) the way to have dynamic stylesheets? 2) How do I stop symfony from adding .css to my stylesheet, or will I have to use mod_rewrite to re-route /css/style.css to /css/style? Thanks. cheers, roel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Re: Setting default permissions for log files? (unable to write to file)
Use the setgid bit (chmod +S) on the log directory and put the batch user in the group that you set on that log directory. cheers, roel Andreas Hucks wrote: Hi all, the server I run my app on will run cronjobs (= symfony batch files) as a different user than the webserver. This is a fixed setting and I am not able to change users for cronjobs. Because of this, my batch files are not able to write to frontend_prod.log. While I can fix this temporarily by adjusting the permissions of the log file, everytime a new log file is created, symfony creates it with write permission for the owner only, creating the problem again. I need to use the frontend app and prod environment for the batch, so the file must be writable for the batch, I can't just use a different one. The directory permissions are not the problem. What can I do to solve this? Is there a way to have symfony create new log files as 777 by default? Cheers, Andreas --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---