Overview

Packages

  • tipy

Classes

  • Tipy
  • TipyApp
  • TipyCli
  • TipyCliSession
  • TipyConfig
  • TipyController
  • TipyCookie
  • TipyDAO
  • TipyEnv
  • TipyFlash
  • TipyInflector
  • TipyInput
  • TipyIOWrapper
  • TipyLogger
  • TipyMailer
  • TipyModel
  • TipyOutput
  • TipyRequest
  • TipySession
  • TipyTestCase
  • TipyTestRunner
  • TipyView

Exceptions

  • AssertionFailedException
  • CompileErrorException
  • CompileWarningException
  • CoreErrorException
  • CoreWarningException
  • DeprecatedException
  • NoMethodException
  • NoticeException
  • ParseException
  • RecoverableErrorException
  • StrictException
  • TipyDaoException
  • TipyException
  • TipyModelException
  • TipyRollbackException
  • TipyValidationException
  • UserDeprecatedException
  • UserErrorException
  • UserNoticeException
  • UserWarningException
  • WarningException
  • Overview
  • Package
  • Class
  • Deprecated
  • Todo

Class TipyController

C in MVC. Receive the request, fetch or save data from a models, and use a TipyView to create HTML output

// app/controllers/BlogController.php
class MyController extends TipyController {
    public function myAction() {
        // your application logic
    }
}

Application input is available in $this->in, application output goes to $this->out

Default template rendering

At the end of the action HTML template will be rendered automatically. Automatic template name is contructed from controller name (without "Controller") and action name

Action                    Template Path
------------------------------------------
BlogController::index()   /app/views/Blog/index.php
BlogController::post()    /app/views/Blog/post.php

Custom template rendering

You can explicitely render template with custom name

// app/controllers/BlogController.php
class BlogController extends TipyController {
    public function article() {
        $this->out('title', 'Hello');
        $this->out('message', 'World!');
        $this->renderView('path/to/custom/template');
    }
}

Disable TipyView rendering

If you use custom template engine or your action outputs formats different from text or HTML you may want to disable default tipy rendering

$this->skipRender = true;
Package: tipy
Located at src/TipyController.php
Methods summary
public
# __construct( )

Instantiate controller with application context

Instantiate controller with application context

public mixed
# in( string $key, mixed $defaultValue = null )

Shortcut to $this->in->get()

Shortcut to $this->in->get()

Parameters

$key
$defaultValue

Returns

mixed
public
# out( string $key, mixed $value )

Shortcut to $this->in->set()

Shortcut to $this->in->set()

Parameters

$key
$value
public string
# renderTemplate( string $templateName )

Render template and return result as a string

Render template and return result as a string

Parameters

$templateName

Returns

string
public
# renderView( string $templateName )

Set custom template name for rendering. This method force controller to render template even if TipyController::$skipRender is set to true

Set custom template name for rendering. This method force controller to render template even if TipyController::$skipRender is set to true

Parameters

$templateName
public
# execute( string $action )

Execute controller action by name with all before/after hooks

Execute controller action by name with all before/after hooks

Parameters

$action
public string
# actionToTemplaName( string $action )

Path to template

Path to template

Parameters

$action

Returns

string
public
# redirect( string $path )

Redirect

Redirect

Parameters

$path
public
# pageNotFound( )

404

404

Todo

Implement fancy 404 page
public
# executeBefore( )

Hook to execute before action. Override this in your controller.

Hook to execute before action. Override this in your controller.

public
# executeAfter( )

Hook to executed after action. Override this in your controller.

Hook to executed after action. Override this in your controller.

Properties summary
public TipyConfig $config
#
public TipyInput $in
#
public TipyOutput $out
#
public TipyEnv $env
#
public TipyView $view
#
public mysqli|null $db
#
public TipySession $session
#
public TipyCookie $cookie
#
protected TipyFlash $flash
#
public boolean $skipRender

Set this to true to turn off TipyView template rendering

Set this to true to turn off TipyView template rendering

# false
tipy API documentation generated by ApiGen