Propel is complaining about a table that doesn’t exist

When you change your mind about your schema, and rename or remove any of your tables from your schema.yml or xml files, you must manually remove all the related classes in the lib/ folder.

Symfony does not delete these unused files when you run a build, so they will stack up and cause Propel errors, for example when calling propel-dump-data.

Of course you can safely delete the lib/om and lib/map folders and run the build again, but you should manually delete the relevant files in /lib as there could be some user generated content in there also. These files are unlikely to cause any errors but might as well be deleted as part of your clean up since they are effectively useless if you have removed their referenced tables from the schema.

Help! Symfony is ignoring my settings in app.yml

Something that just cropped up today…

As your site grows, and you add more and more config to the app.yml file, be very careful not to re-declare the same named element. Symfony will not warn you, and there will be no errors - but the second (lower) instance will simple overwrite the first!

For example, if you have forgotten that you already have an element called profile hiding near the top of the file, and you add another one called profile at the bottom, with all your profile page settings - the lower one will destroy the one higher in the file.

This can be hard to spot if you have been meticulously coding and added a default value to all your sfConfig::get() calls because chances are when you are developing the site, all your defaults will be the same as the ones you have specified in app.yml.

The problem will become apparent when an end user tries to change the configuration and the change is ignored, because Symfony is simply using the default value rather than the one the user thinks they are setting.

Careful out there kids!

UTF-8 and strlen()

Trying to find out the length of a string and wondering why the values are often wrong?

UTF-8 characters can be multi-byte, and strlen() returns the length of the string in bytes, which means the string ååå would actually have a “length” of 6.

One solution is to use the multibyte function “mb_strlen” instead, you will need to have PHP compiled with this - but it seems to be a default in later versions.

E.g.

$value = "ÅØÆbob";
echo strlen($value);
// 9
 
echo mb_strlen($value, 'UTF-8');
// 6

I18n is for life (actions), not just for Christmas (templates)

Well, the point is make sure you Internationalise everything, not just the text you have in the templates.

For example, when using ajax calls you may be rendering text directly from actions, or you may be throwing exceptions which have meaningful error messages which are displayed by the template. You need to remember to “i18nalise” this text too…

From an action, you can access the i18n function via the context singleton, as documented by the Symfony docs (http://www.symfony-project.org/book/1_0/13-I18n-and-L10n)

$this->getContext()->getI18n()->__("yourtexthere");

Remember to do it now, and you won’t kick yourself later!

How to click an image in sfBrowser (symfony lime testing)

This is probably a really simple point, but it actually took me a few searches and tries to find the answer - but it’s quite simple really, just use the image’s alt tag attribute.

If you are using the symfony image_tag helper and not specifying your own alt attribute, then it will be the image name minus the extension, for example - if your template contains this link:

 

then in your Functional test, use:

$b->click("fred");

« Previous PageNext Page »