September 15th, 2008
Zend has a wonderful XML RPC library built into their framework. You create a class with member functions that are accessible via RPC. It even uses heredoc syntax for the typing of parameters. All you have to do is register the class with the XML RPC server and it automagically works.
Unless it doesn’t. Which is where the hard part comes in. As a client there’s no way to see the raw HTTP response from the server. You can grab the Zend_Http_Client from the Zend_XmlRpc_Client. This will give you access to
Zend_Http_Client->raw_post_data
which is how Zend_XmlRpc_Client sends the request. The response however, is much harder to get. When Zend_XmlRpc_Client receives a response it uses a Zend_Http_Response, but it’s never stored. It passes the data over to a Zend_Xml_Response and returns that. Which is great if the page is valid XML. But if PHP throws an exception or you just want to look at the raw HTTP it’s gone. To get around this I added a variable to the Zend_XmlRpc_Client to store the Zend_Http_Response before it’s destroyed. Then added in a function to return it and voila. To check the raw response you just have to
Zend_XmlRpc_Client->getLastHttpResponse()->getBody()
Filed in Zend | No Comments »
September 11th, 2008
I recently spent several hours beating my head against the wall trying to figure out why Doctrine and Zend weren’t playing nice together. I was using the version of Apache and PHP that comes with Mac OS X Leopard. When trying to load up the site in my Zend framework I got the error:
Warning: Zend_Loader::include_once(Doctrine/Adapter/Mysql.php): failed to open stream: No such file or directory
Which made me think I was missing the mysql adapter for Doctrine. Looking in the Doctrine/Adapter folder, at least with the latest version, you’ll notice there is only a Mysqli.php no Mysql.php. This led me to think that I was missing some essential library for Doctrine. However, this was not the case. The issue is that the build of PHP that comes with Mac OS X Leopard does not include pdo_mysql. The extension is listed in the php.ini file and you can uncomment it, but it won’t load. Rather than try and compile PHP with pdo_mysql support I decided to move to MAMP. Which turned out to be a wonderful choice. It’s got pdo_mysql support in its PHP build. It’s also a great way to do local development since you can easily turn it on, or restart. I would highly recommend it for development on your local machine.
Tags: adapter, Doctrine, leopard, mac, mysql, mysqli, os x, pdo_mysql.php, php, Zend
Filed in Doctrine, Zend | 6 Comments »