phramework doc
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Namespaces

  • Phramework
    • Authentication
    • Database
      • Operations
    • Exceptions
    • Extensions
    • Models
    • URIStrategy
    • Validate
    • Viewers

Classes

  • Phramework

Class Phramework

API 'framework' for RESTful services
Defined settings:

  • boolean debug, [Optional], default false
  • string errorlog_path [Optional], default is null
  • string language [Optional], default is "en"
  • string[] languages [Optional], default is []
  • string[] allowed_referer [Optional], default is null
Namespace: Phramework
License: Apache-2.0
Author: Xenofon Spafaridis nohponex@gmail.com
Version: 1.2.0
Link: Developer's website
Todo: Clean GET callback
Todo: Add translation class
Todo: Add allowed origin settings and implementation
Todo: Add setting for timezone
Located at Phramework.php

Methods summary

public
# __construct( array $settings, Phramework\URIStrategy\IURIStrategy $URIStrategyObject, object|null $translationObject = null )

Initialize API

Initialize API

Only one instance of API may be present

Parameters

$settings
$URIStrategyObject

$URIStrategy URIStrategy object

$translationObject
[Optional] Set custom translation class

Throws

Phramework\Exceptions\ServerException
public static Phramework\Phramework
# getInstance( )

Returns

Phramework\Phramework
public static string
# getRequestUUID( )

Get UUID generated for this request

Get UUID generated for this request

Returns

string
public static
# setTranslation( Phramework\Extensions\Translation $translationObject )

Set translation object

Set translation object

Parameters

$translationObject
Translation object
public static type
# getTranslated( string $key, object|array|null $parameters = null, string $fallbackValue = null )

Shortcut function alias of $this->translation->getTranslated

Shortcut function alias of $this->translation->getTranslated

Parameters

$key
$parameters
$fallbackValue

Returns

type

Todo

implemtation
public
# invoke( )

Execute the API

Execute the API

Throws

Phramework\Exceptions\PermissionException
Phramework\Exceptions\NotFoundException
Phramework\Exceptions\IncorrectParametersException
Phramework\Exceptions\RequestException

Todo

change default timezone
change default language
initialize database if set
@security deny access to any else referals
public static stdClass|false
# getUser( )

Get current user

Get current user

Returns

stdClass|false

Get current user's object, false in case of non authenticated request

public static integer
# getTimezoneOffset( )

Get timezone offset in minutes

Get timezone offset in minutes

This value is based on user's timezone

Returns

integer
Returns offset from UTC in minutes

Todo

Implement, get user's data
public static string
# getLanguage( )

Get current language

Get current language

Returns

string
Current language
public static string
# getMethod( )

Get requested method

Get requested method

Returns

string
public static string
# getController( )

Get requested controller

Get requested controller

Returns

string
public static string
# getViewer( )

Get current viewer

Get current viewer

Returns

string
public static string
# getCallback( )

Get callback if set

Get callback if set

Returns

string
public static Mixed
# getSetting( string $key, string|null $secondLevel = null, mixed $defaultValue = null )

Get a setting value

Get a setting value

Parameters

$key
The requested setting key
$secondLevel
$defaultValue
[optional] Default value is the setting is missing.

Returns

Mixed
Returns the value of setting, null when not found
public static
# setViewer( string $viewerClass )

Set viewer class

Set viewer class

Parameters

$viewerClass
A name of class that implements \Phramework\Viewers\IViewer
public static mixed
# view( object|array $parameters = [] )

Output the response using the selected viewer

Output the response using the selected viewer

If requested method is HEAD then the response body will be empty Multiple arguments can be set, first argument will always be used as the parameters array. Custom IViewer implementation can use these additional parameters at they definition.

Parameters

$parameters
The output parameters.

Returns

mixed
Returns the value returned by the invoked viewer
public static
# writeErrorLog( string $message )

Write a message to log file

Write a message to log file

Parameters

$message
message to write

Todo

improve

Constants summary

METHOD_ANY
# null
string METHOD_GET
# 'GET'
string METHOD_POST
# 'POST'
string METHOD_PUT
# 'PUT'
string METHOD_DELETE
# 'DELETE'
string METHOD_HEAD
# 'HEAD'
string METHOD_PATCH
# 'PATCH'
string METHOD_OPTIONS
# 'OPTIONS'
string METHOD_TRACE
# 'TRACE'

Properties summary

protected static Phramework\Phramework $instance
#
protected static string $requestUUID

UUID generated for this request

UUID generated for this request

#
public static Phramework\Extensions\StepCallback $stepCallback

StepCallback extension

StepCallback extension

#
public static Phramework\Extensions\translation $translation

translation extension

translation extension

#
public static string[] $methodWhitelist

Allowed HTTP methods

Allowed HTTP methods

# [ self::METHOD_GET, self::METHOD_POST, self::METHOD_DELETE, self::METHOD_PUT, self::METHOD_HEAD, self::METHOD_OPTIONS, self::METHOD_PATCH ]
phramework doc API documentation generated by ApiGen