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

Namespaces

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

Classes

  • ClassBased
  • URITemplate

Interfaces

  • IURIStrategy

Class ClassBased

ClassBased strategy will use the controller parameters extracted from URI and will attempt to include the respective class.

Optionaly apache's configuration via .htaccess can convert the url from:

/?controller={controller}&resource_id={resource_id} to /{controller}/resource_id

and

/?controller={controller} to /{controller}

RewriteEngine On

#Site full url with id
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z]{3,})/([a-zA-Z0-9_|%2520]+).*$ index.php?controller=$1&resource_id=$2 [L,QSA]

#Site full url
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z]{3,}).*$ index.php?controller=$1 [L,QSA]
Phramework\URIStrategy\ClassBased implements Phramework\URIStrategy\IURIStrategy
Namespace: Phramework\URIStrategy
License: Apache-2.0
Author: Xenofon Spafaridis nohponex@gmail.com
Since: 1.0.0
Todo: document default_controller setting
Todo: Add documentation for setting default_controller
Located at URIStrategy/ClassBased.php

Methods summary

public
# __construct( array $controllerWhitelist, array $controllerUnauthenticatedWhitelist, array $controllerPublicWhitelist, string $namespace = '', string $suffix = '' )

Initialize ClassBased IURIStrategy

Initialize ClassBased IURIStrategy

Parameters

$controllerWhitelist

Array with the allowed controllers

$controllerUnauthenticatedWhitelist

Array with the controllers which can be accessed without authentication

$controllerPublicWhitelist

Array with the controllers which can be accessed without authentication

$namespace
Controller's namespace
$suffix
[Optional] Default is NULL
public string[2]
# invoke( object & $requestParameters, string $requestMethod, array $requestHeaders, object|false $requestUser )

Invoke URIStrategy

Invoke URIStrategy

Parameters

$requestParameters
Request parameters
$requestMethod
HTTP request method
$requestHeaders
Request headers
$requestUser

Use object if successful authenticated otherwise false

Returns

string[2]
This method should return [$class, $method] on success

Throws

Phramework\Exceptions\NotFoundException
Phramework\Exceptions\UnauthorizedException
Phramework\Exceptions\ServerException

Implementation of

Phramework\URIStrategy\IURIStrategy::invoke()
phramework doc API documentation generated by ApiGen