PHP Classes
elePHPant
Icontem

CC Classes & Objects: Retrieve classes from API with specific functions

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2014-11-16 (7 months ago) RSS 2.0 feedNot enough user ratingsTotal: 298 All time: 6,759 This week: 1,468Up
Version License PHP version Categories  
cc-classes 1.0Free To Use But R...5.0PHP 5, Web services, Performance and ...
Description Author  

This class can retrieve classes from API with specific functions.

It can send HTTP requests to an API Web server to retrieve the code for specific classes.

The retrieved classes contain only specific functions defined in the request parameters.

The retrieved class files are stored in local files to avoid future API access overhead.

Innovation Award  
PHP Programming Innovation award nominee
November 2012
Number 6


Prize: One copy of VS.PHP
Some Web service APIs provide a very long list of functions. Writing code to access all API functions may be a tedious task to do manually.

This class provides an alternative that consists in generating a small class with code for only the functions an application needs.

The actual Web service API provides the PHP code to access the specified API functions.

Manuel Lemos
Picture of PLSCIS PLP
Name: PLSCIS PLP <contact>
Classes: 3 packages by
Country: India India
Age: ???
All time rank: 109958 in India India
Week rank: 65 Up7 in India India Up
Innovation award
Innovation award
Nominee: 1x

Details provided by the author  
Api parameters:-

1) api url: http://www.plsein.in/api/cclass

2) post parameters:
   > params: array containing req. info about class file to be generated
		> cn: classname (its name of the class in the class file, make sure file does not contain multiple classes, multiple classes in same file are not supported)
		> fn: functions (comma separated case sensitive name of functions to be used from the class file)
		> fc: class file content (oroginal class file content)
		> bsf: y means fc is base64encoded and n means is not base64encoded
	> ui: array containing user identification parameters
		> sec_code: value of secret code (will be available from profile page)
		> key: value of secret key (will be available from profile page)

3) response:
	> dtls: array of details returned back from api
		> fc: new file content (store it an some place for later use in project in place of original file)
		> bsf: y means fc is base64encoded and n means is not base64encoded
		> er: error information if any error occured during image creation

> example given in cc_test.php is just a demo for how to call api and use its out-put, its recomended to call this cc classes api only once all development is completed and tested and just before making application live so that there are no further changes in original code and generated cc files are final.

> also make sure once generation of all files are over make sure once application is in live mode it does not make any call to the api else your application it will perform slow as it will call api every time.

> given code is not for a automated process to generate 'curtailed concise classes' for all class files in a project, its only a demo code for one file.

> but you can modify this code and integrate in you current project such that it will create 'curtailed concise classes' as per req. whenever any webpage is opened and thus for every webpage you will get req. cc-classes

> if there are same functions used in more than one page only one cc-class will be created (note once again not to call the api in live mode of your application)

> In-case of any doubt, please feel free to contact us through contact page on our website http://www.plsein.in/contact/

> Note on limitations:

- If in any function of your class file 
  i) there is not a matching '{' and '}' pair like:
        $v = '/[a-z]\}/'; 
    OR 
        $v = '/[a-z]\{/'; 
    OR 
        $v = '/[a-z]\}{/';
OR
   ii) there is some commented text with unmatched pair of '{' or '}' like: 
      // comment text { ...
    OR
      // comment text } ... 
    OR
      // comment text } ... { ... 

- in any such cases please put #functionName_fn_ends# immediately after ending '}' of that function like:
  For e.g.: 
    function is getLoginUrl() and it contains unmatched '{' or '}' pair then the ending curly bracket of that function must be followed by #getLoginUrl_fn_ends# like this: }#getLoginUrl_fn_ends#

- Also, if there is more than one occurance of  text "function getLoginUrl() {" than there is a possibility that generated file is not proper, so please verify generated file by yourself in such cases. Chances to have such situation in a php class is very much less as there is no function overloading supported, but still if repeation is there even in commented text it may not give correct output, so you will have to remove (or rename) reused function names if any in same class.

[hope you won't mind taking care of this (i.e. modifying the class code if req. as per senario explained above) before using api, against the performance gain].
  Files folder image Files  
File Role Description
Plain text file cc_classes.php Class php class for calling cc-classes api
Plain text file cc_test.php Example sample code to demonstrate use of cc classes api through cc_classes.php class file
Plain text file readme.txt Doc. documentation file

 Version Control Unique User Downloads Download Rankings  
 0%Total:298All time:6,759
 This week:0This week:1,468Up
 User Comments (1)  
 
Not clear what this package really does.
2 years ago (CPK Smithies)
35%StarStar