Beauty’s where you find it
15 Jul
I completely embrace the idea of coding standards, and for a long time I’ve used my own. This morning I have decided that from now on I will be following the coding standards set fourth by the Zend Framework.
http://framework.zend.com/manual/en/coding-standard.html
This is a decision I don’t make lightly, and one that I have been toying with for a long time. Do you have a particular set of standards you follow?
26 May
Quite often I find myself overwhelmed by the amount of news I try to consume on a daily basis. Often the result, unfortunately, is that my brain shuts down to some extent and I find it hard to prioritize the things I really want to investigate. For example, ever since the January 2008 edition of PHP | Architect, in which there was an article about The Doctrine Framework, I have been trying to find the time to dig in. On the way into work today I made the decision that, on a weekly basis, I would begin investigating things that interest me. This week of course is devoted to Doctrine.
What is Doctrine? According to the website:
Doctrine is a PHP ORM (object relational mapper) for PHP 5.2.3+ that sits on top of a powerful PHP DBAL (database abstraction layer). One of its key features is the ability to optionally write database queries in an OO (object oriented) SQL-dialect called DQL inspired by Hibernates HQL. This provides developers with a powerful alternative to SQL that maintains a maximum of flexibility without requiring needless code duplication.
Ok, sounds good to me. Let’s get started. (more…)
14 May
I have used http_build_query numerous times in the past and I’ve never had to pay attention to the third parameter before: arg_separator. I am making use of a great Curl wrapper to abstract some of the more mundane setup tasks associated with a Curl request. Initially I had constructed the setup of CURLOPT_POSTFIELDS as follows:
$url = 'http://rest-toolkit/api/users/5';
$response = $curl->post($url,
$vars = array(
'username' => 'baz',
'password' => 'bar'
)
);
...
curl_setopt($handle,
CURLOPT_POSTFIELDS,
http_build_query($vars)
);
Upon receiving the request, my script was showing $_POST variables as follows:
Array
(
[username] => baz
[amp;password] => bar
)
Thanks to a comment on the http_build_query page regarding the use of the third parameter, I quickly realized that my php.ini setting for arg_separator.output was in fact set to &. The quick fix:
curl_setopt($handle,
CURLOPT_POSTFIELDS,
http_build_query($vars, '', '&')
);
And the result:
Array
(
[username] => baz
[password] => bar
)
5 May
This morning I got into work early (6:30am, which is early for me) and decided to add the ability to define special methods to Rest Toolkit (original blog entry). “Special” in this case means adding the ability to call specific methods which allow special processing for a resource. (more…)
1 May
I recently finished my first CakePHP application. Not only was the application the largest I have ever written, but I had never worked with CakePHP before. So, needless to say, not only did I have to overcome a learning curve, but I had to deal with all that comes with writing a large application. Today I was contacted by the project manager regarding a bug which had surfaced in the application. In my quest to squash the bug I discovered a script which was causing a section of the administrator to act very sluggish. In examining exactly what was going on, I realized that there were 200+ calls being made to the database. Ok. That’s bad. I’d like to clarify that I was the one who wrote the original offending code. In about 2 minutes of work I was able to bring the query count down to 2, and reduce the page response time considerably. (more…)
28 Apr
Yes, I know, displaying the time with JavaScript. Something that’s been written about since the dawn of time. Following is a trivial bit of code, but one that I thought others might find useful. We are working with a client whose application broadcasts meetings (and screen captures from those meetings) to client computers. A very cool project that I’d like to write about some day. With regard to time, there are 2 requirements:
22 Apr
I’ve had my focus in a lot of other areas for a few weeks, and in that time is seems like quite a bit has happened on the CakePHP front. It seems that there has been a subtle shift in how the framework will evolve from here forward. gwoo puts it much better than I can in his recent bakery article, “After 3 years, looking back and moving ahead“. In the grand scheme of things there are much more interesting things between the lines of what gwoo has written, however the thing that got me most excited was located at the very end:
Stay tuned for more new developments and expect the next 1.2 release in the coming weeks.
21 Apr
Last week Dave and I were trying to figure out the best way to synchronize member data from an asp application with a WordPress installation. I don’t remember how it came up in conversation, but in a flurry of chatter we decided that we should build a RESTful API to allow the applications in question to communicate. In the interest of re-usability we also decided that we should build a generic toolkit. One that could easily be used to expose an API for any supported database, through PHP. So, using this toolkit you should quite easily get your Lasso application talking with your PunBB software, if that’s what you need.
So was born rest-toolkit. We have released an alpha version of the project, so download it and give it a try. I hope you don’t mind a lack of formal documentation. Depending on how things go documentation will follow. (more…)
18 Apr
Recently I worked on a project where all member data was being managed through a third party member management service, provided by a company named Avectra. The product does more than manage member data from the looks of things, but all I cared about was interaction with the member management API.
I had to authenticate against an external data source, as well as query the data source for member information when needed. Avectra does have a web service API which it has named xWeb. Here is a quote from their Wiki:
xWeb is netFORUM’s XML web services application. netFORUM is an enterprise level Association Management System (AMS) developed by Avectra that allows associations to manage their customers and related activities. netFORUM is used by association staff, members, and the public at large.
14 Apr
I recently had the need to set up some permanent redirects for an application built on CakePHP. My first thought was to use a simple .htaccess Redirect at the top of my www .htaccess file, like such:
Redirect 301 /foo /bar
However, the result of the redirect was actually the following url:
http://foobar.com/bar?url=foo
This has to do with the QSA flag in the last RewriteRule of the root htaccess file. The QSA flag indicates that a query string should be appended to the url. In our case, foo is recognized as the query string and it ultimately is appended at the end of the bar redirect. Not what I wanted, as the appending of foo to bar results in a 404 error. (more…)
Recent Comments