Hard found gains in Symfony

My first production Symfony application is a newletter manager and sender. This gave me a few headaches that I couldn’t easily find solutions for in the Docs. In the end trial, error and other sources came up with some gems that kept things moving.

Assigning complete module output to a variable


This is pretty useful, dropped into your Action this retrieves the fully rendered (layout, template, content) output of another Action/Module. Many of the email examples recommend putting the content you wish to send out into a partial or component and show how to grab it for variable assignment, but this will take a whole page you might want to email ‘as is’. I use it retrieve a current newsletter page as it is would be rendered for the web so I can drop it into an email.

Flexible but full Absolute URLs to assets

  stylesheets:    [main , 'http://mysiteDotCoDotUK/path/to/this.css']
  javascripts:    ['http://mysiteDotCoDotUK/path/to/that.js']

The books don’t seem to mention it, but you can use absolute URLs in your view.yml for embedding stylesheets and javascripts. So you can set granular stylesheet and script settings down to the module while still producing absolute links to them. When your assets also use the absolute=>true boolean options in Link and Asset Helpers, then you have dynamically generated fully standalone output. I’ll be using this to make sure email newsletters find their supporting content.

With this, I can provide the editor interface, management and preview options, a live copy of the current newsletter and archive of old ones on the web, and share the very same content in mails to subscribers.