All in vain

Some rants about technology, PHP, people, tools, web etc from a developers perspective. Feel free to copy ideas, code or anything from here.

Tuesday, February 28, 2006

Simply the best PHP framework

No comments
My search has ended. I think i have found the best PHP application development framework. After so many hours of searching, installing, configuring so many frameworks from sourceforge, freshmeat etc, i have found the best solution for my problems. Ok let me explain a few things here. I wanted a framework which:
  • Is flexible.
  • Is easy to use.
  • Doesnt force a design pattern.
  • Dont overdo the MVC, Ajax etc.
  • Provides a stable base for my applications.
And the winner is............. PHP2GO framework!

Using it is extremely simple. You can even use it with your existing applications. It doesnt forces itself on you. This framework in my opinion is the ideal for my needs. It makes so many day to day tasks so simple that it makes u think "why didnt i think of it".

I would rate it above some other frameworks i tried. For one its footwork is so small, you can strip it of unwanted functionality and it comes to around 800K.

Basic usage is like this:
  • U define a config file to suite your needs.
  • U include this file in any file you make.
  • Import classes u plan to use (Forms, templaes etc....)
  • initialise the classes and provide it with details and you are done.
Take a look at the example directory and u can find some very good examples. The most striking feature is how u can define your forms structure in XML and it generates form from it! Its so simple.

I would look into it more thoroughly but whatever time i have spent on it has made me cry with joy. OSS rules.

Saturday, February 18, 2006

PHP and SOAP

4 comments
I mentioned in one of my previous posts how i accessed the betfair api. The reason i am mentioning it again is because of this site. I owe quite a lot of things to this site. When i was banging my head against the wall to find a solution to my problems i found pattemplate to be quite helpful. Not that it has anything to do with SOAP.

Here is a summary of my problem, i needed to access the api through PHP and the documentation on their site was not helpful. Then i came across some code which used NuSOAP library. The response was very slow, and also the class i used was not sufficient to handle all the operations allowed in the API. To complicate matters further the Betfair people switched to a new version of their api and i was left on my own to find a solution. Then in one of the Perl forums i found a snippet where somebody (god bless him!) showed some code on how to send a raw request to a soap server.

I latched onto that chance and digged in PHP to find equivalent solution. Here is what i did. I converted the XML request data into templates and used Pat-template system to fill-in the values. Then i used the excellent Curl library to send raw POST request to the betfair SOAP server and tada! we got response.

//function to execute curl calls
function call_curl($xml)
{
$user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";

$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL, API_URL ); // set url to post to
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 60); // times out after 1 min
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml ); // add POST fields

if( LOCAL )
{
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
}

curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);

$header[] = "SOAPAction: ". API_URL;
$header[] = "MIME-Version: 1.0";
$header[] = "Content-type: text/xml; charset=utf-8";

curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$result = curl_exec($ch); // run the whole process


if (curl_errno($ch))
{
print curl_error($ch);
return 0;
}
else
{

//now that we have got a result, parse this soap packet and return the XML doc
$parser = new soap_parser($result,'UTF-8','',TRUE);
$result = $parser->get_response();

//print_R($result);
curl_close($ch);

if($result["Result"]["header"]["errorCode"] != "NO_SESSION" )
{
update_session_key($result["Result"]["header"]["sessionToken"] );
}

return $result;
}

}//function ends



The rest as they say was history ;-) Btw if u dont know anything about Curl library i would advise u to give them a visit. It is an excellent tool. I have used it in various projects and here are a few of the uses i could find in my experience:
  • Form POSTing
  • Downloading a file and saving it to disk
  • Uploading files to a FTP server with authentication
  • Spidering!
  • Loggin in to a site and navigating through password protected areas and downloading feeds etc.
  • Telnet
  • Data transfer between servers
Thats it i guess for the moment, but before i go heres what u can expect in my coming posts: More about some other unix tools like NetCat, Dig, Socat etc and my new PHP development Framework.

Tuesday, February 07, 2006

I need RAM

No comments
I need RAM and lots of it :-) Just installed Kanotix and my system takes a dive every time i run XAMMP. For those of you came late, XAMMP is a all in one solution for a web server. So if you dread compiling and configuring Apache + MySQL + PHP and rest u need to take a look at this. It works on most systems.

So where was i?? Yes i need RAM My current rig runs AMD(what else ;-) ) duron 1.2 Ghz with 128Mb RAM. It was fine until i upgraded my distro to kanotix that i noticed my machine was thrashing while working. This made me search for distros which were not hard on configuration and would run fine with old systems. This took me to SLAMPP which is based on SLAX but comes with XAMPP preinstalled..

Lets see if it works otherwise i have to buy some RAM for my old PC. If you are interested in finding the right distro for u may i suggest distrowatch it lets you search on so many parameters.

BTW linux is the way to go if u want to learn about real computing. How things work underneath. And running linux is cool too. For developers it is the best, unless ofcourse you work on Micro$oft technologies. If u work on .NET u might be interested in MONO. This project makes it possible to run .NET on apache

hey did u visit my site on zeeblo. You should cause i have just installed JAWS CMS on it and it rocks.
See my site: