Niklas Närhinen
An easy way to update propel from github

We were using svn:externals to keep Propel ORM (and other libs) up-to-date in our projects. (You should always have your libraries project-local).

Recently Propel ORM switched to GitHub.

I wanted to keep my development process lean and highly automated, that’s why I wrote this bash-script to update Propel to the desired tag.

Hope it will be useful to others also (use at own risk..)

Comments
Streaming output with a callback in Agavi

Earlier I wrote about serving large XML contents with PHP.

Today I wanted to  use that knowledge when outputting from Agavi.

By default you would output XML like:


class Products_ListSuccessView extends MyProductsBaseView
{
	
	public function executeXml(AgaviRequestDataHolder $rd)
	{
		$dom = new DOMDocument();
		........
		return $dom->saveXML();
	}
}

Changing this according to my previous blog post about XML isn’t just replacing the DOMDocument with XmlWriter as AgaviWebResponse sends headers only after the view’s execute-method has completed.

So I had to subclass AgaviWebResponse to support returning Closures from the view:


class MyWebResponse extends AgaviWebResponse
{
	public function sendContent()
	{
		if ($this->content instanceof Closure) {
			$func = $this->content;
			$func();
			return;
		}
		parent::sendContent();
	}
}

After adding the class to autoload.xml and factories.xml you can do the following:


class Products_ListSuccessView extends MyProductsBaseView
{
	
	public function executeXml(AgaviRequestDataHolder $rd)
	{
		return function() {
			$writer = new XmlWriter();
			$writer->openURI('php://output');
			.......
			$writer->flush();
		};
	}
}

Wasn’t that simple? :)

Comments
Bind NHibernate objects to WPF DataGrid

Lately I have felt the need to try out Windows Presentation Foundation. I have been using WinForms with Ado.NET providers but it just feels I’m coupling too much business logic with the user interface.

Windows Presentation Foundation seems very promising for implementing the Model-View-ViewModel pattern. Specifically when combined with an ORM, like NHibernate. Even though this post isn’t implementing the pattern properly, it should give you the direction technically :). I will be using NHibernate, Fluent NHibernate and SQLite for the examples.

Read More

Comments
Creating and Serving large XML files: DOMDocument vs. XmlWriter

Handling big amounts of data between a client application and a REST service can sometimes be tricky, especially when things should be responsive. I did a small benchmark between the built-in tools in PHP: DOMDocument and XmlReader.

Read More

Comments