Hattrick Client CHPP framework for PHP Code
Brought to you by:
odiobill
File | Date | Author | Commit |
---|---|---|---|
test | 2008-07-04 | Odiobill | [r43] Ready for the rc1 release. |
CHPP.php | 2008-10-23 | Odiobill | [r48] Small bugfixes. |
HTClient.php | 2008-10-23 | Odiobill | [r48] Small bugfixes. |
HTRatings.php | 2008-10-15 | Odiobill | [r45] HTClient version 2.0 gold! |
HTTranslate.php | 2008-10-15 | Odiobill | [r45] HTClient version 2.0 gold! |
HT_Module.php | 2008-05-21 | Odiobill | [r13] Code cleanup. |
README | 2008-10-15 | Odiobill | [r47] Updated documentation. |
chppxml.php | 2008-10-23 | Odiobill | [r48] Small bugfixes. |
languages.xml | 2008-06-27 | Odiobill | [r36] HTClient.php: fixed htPlayers(). |
test.html | 2008-10-15 | Odiobill | [r46] Ready for HTClient 2.0 gold! |
test.js | 2008-10-15 | Odiobill | [r46] Ready for HTClient 2.0 gold! |
test.php | 2008-10-15 | Odiobill | [r46] Ready for HTClient 2.0 gold! |
HTClient 2.0 HTClient 2 is an Open-Source CHPP framework for PHP/5+ developers. It is based on the new Hattrick CHPP API and of course supports the new login system. HTClient is fast. You will get fast results for your requests because of the advanced, transparent cache system. Your server will load the code fast, because of the lightweight design and the simple but flexible API. Development of your application will be fast, because you can save many lines of code issuing desired parameters to higher level functions to retrieve more details without specifically request every information needed. This new realease is modular and more object-oriented than previous monolithic implementations. All the information fetched from Hattrick servers is available as an array, so accessing data is extremely fast. Moreover, using an array makes very easy to pass values you want to other environments than PHP: with a simple json_encode() call, you can provide details to Javascript code (AJAX applications) or Flash applications (using a default ActionScript function). If you still don't need these features and you prefer a more object-oriented approach for a "PHP only" application, then you can relay just on the core module of this package and PHP SimpleXML for parsing the result provided by htFile(). This function is very easy to use: simply provide details about the CHPP page you want to fetch and requested parameters, and then manage the result in the way you prefer. You can obtain the resulting array or even the unparsed XML file, choosing to handle the obtained information for other HTClient features, or to get it directly with no overhead: if developer does not need all the high level functions of HTClient, he can safely use just CHPP.php, obtaining an extremely compact application. But is also possible to extend through the HTClient class, for example to redefine some of the provided methods allowing to save or read the information even from a local database instead of relying only on what obtained from XML files or the current session cache. HTClient should now be interpreted as a lighweight Open-Source CHPP framework for PHP/5+ developers, instead of an helper class like before. Every developer can provide contributions in different modules. There is place for help from everyone, and of every kind. PHP cURL extension is required for HTTP communications to obtain faster downloads and a much more lighter code: if it is true that this extension is not available on all the servers, we also have to consider that there are similar problems with fsockopen() calls previously used with other ones. This offers also an easy way to use a proxy server for downloading the XML files. At the moment, this framework provides the following modules: - HTClient.php Main class, offers an high level abstraction (and management) of the internal cache, providing several functions to retrieve information from Hattrick servers. This information will be generally cached and made available on sucessive calls without the need for other HTTP connections. Requires the core CHPP.php module. - CHPP.php Core module that implements the htFile() function that is used to download every available CHPP XML file. If you don't need all the high level features of HTClient, you can use just CHPP.php by itself, obtaining an extremely compact application. - HTRatings.php Collects data from fetched matches to extend directly available information. This will be useful for further analisys or to compare team and player values. It provide also a very fast way for obtaining higher level information as the best players for a match or to search for possible ratings of a composed lineup. - HTTranslate.php Every provided function will extend the amount of stored information with translations composed parsing available data, choosing for almost every language supported by Hattrick, where values are read from an XML file. HTClient sample application This is a simple AJAX interface to a PHP backend service that is build using HTClient 2.0, written to show how is easy to write a CHPP application with this development framework. It is Open-Source and directly provided along the HTClient package. Once logged in, every called HTClient (and related modules) function will be logged in a console box. The javascript code (test.js) is used to read information provided by HTClient and to display it following the common Web 2.0 approach, while every request is managed within a single PHP file (test.php). Main goal for this project is providing a practical tour with some HTClient features, using the main class and other modules (currently, HTRatings and HTTranslate). If you want to try the HTClient sample application without downloading it, feel free to visit http://htclient.hattrickhq.org/ Best regards, //CHPP-Odiobill