abstract class Treaty (View source)

Constants

SLASH

NOSLASH

Properties

static protected string[] $allowedMethods

Methods

__construct(App $context, int $modes)

Create routes basead in a Controller or other Class

bool
mount()

Scans public instance methods and registers matching ones as routes.

static 
dispatch(int $modes = 0)

Instantiates the controller and dispatches its routes against the global $app.

static string
formatPath(string $path)

Converts a class method suffix to a kebab-case URL segment.

Details

__construct(App $context, int $modes)

Create routes basead in a Controller or other Class

Parameters

App $context
int $modes

Exceptions

Exception

bool mount()

Scans public instance methods and registers matching ones as routes.

Returns true if at least one route was registered, false otherwise.

Return Value

bool

static dispatch(int $modes = 0)

Instantiates the controller and dispatches its routes against the global $app.

Intended as a one-line convenience call from route definition files. Throws if the global $app is unavailable or no routes are found.

Parameters

int $modes

Exceptions

Exception

static protected string formatPath(string $path)

Converts a class method suffix to a kebab-case URL segment.

Examples:

  • public function postFooBarBaz() becomes foo-bar-baz.
  • public function getUserID() becomes user-id. Note: Override this method to customize path formatting.

Parameters

string $path

Return Value

string