Difference between revisions of "GMOD RPC API/PHP"

From GMOD
Jump to: navigation, search
(gmod-rpc/v1/services/)
m (Text replace - "</php>" to "</syntaxhighlight>")
 
(One intermediate revision by the same user not shown)
Line 29: Line 29:
 
  class.Service.php
 
  class.Service.php
 
implement additional services by adding object classes that extend this base class e.g. class.Organisms.php:
 
implement additional services by adding object classes that extend this base class e.g. class.Organisms.php:
<php>
+
<syntaxhighlight lang="php">
 
class Organisms extends Service{
 
class Organisms extends Service{
 
...
 
...
</php>
+
</syntaxhighlight>
 
Service class names should be ucfirst.
 
Service class names should be ucfirst.
  
 
==== gmod-rpc/v1/class.View.php ====
 
==== gmod-rpc/v1/class.View.php ====
 
A views object to generate xml or json
 
A views object to generate xml or json

Latest revision as of 18:12, 9 October 2012

Plans/Architecture for the PHP tools for implementing gmod-rpc

Components

index.php

gmod-rpc/index.php

Use mod_rewrite so that gmod-rpc URLs all go to this script

<IfModule mod_rewrite.c>   
RewriteEngine on  
RewriteRule ^/gmod-rpc/.*$ /gmod-rpc/index.php  
</IfModule>

index.php looks for a version directory based on the URL.

class.myDomDocument.php

Very small class from Joe Grissom at Oklahoma for making XML. There is probably something more sophisticated that could be used in the future, but this works.

version directories

put everything else in a directory based on the version, e.g. v1

gmod-rpc/v1/rpc.php

All this does is parse the URL to instantiate a contoller object for the desired service and a view object. The class files live in

gmod-rpc/v1/sources/

This will be where data source adaptors live class.SourceName.php/

gmod-rpc/v1/services/

This directory holds a file defining a base class

class.Service.php

implement additional services by adding object classes that extend this base class e.g. class.Organisms.php:

class Organisms extends Service{
...

Service class names should be ucfirst.

gmod-rpc/v1/class.View.php

A views object to generate xml or json