I don't mind trading my opinion for a better one,
but not for one with equal or lesser value.
- My father

Intention.php

  • Intention.
  • IntentionCache.
  • IntentionController.
  • IntentionDatabase.
  • IntentionError.
  • IntentionLog.
  • IntentionLogger.
  • IntentionModel.
  • IntentionTest.
  • IntentionView.

Meet Mr. Intention.


TODO : Add better routing that also takes care of custom routing Get rid of either the bootstrap or the config


Intention library class. This is where the magic happens.


Sets the autoloader , adds certain data to the configuration and maps the parameters if provided.

@param array $params Parameters for the page
@param array $config An array containing necesary configuration

Starts the application , will call the requested controllers and sets up the view.

@param boolean | string $bootstrap If specified will load a bootstrap file
@return string $content The content retrieved from the controller / view / whatever is called

The autoloader

@param string $class The class to be loaded

Adds a route to Intention must contain an array with the regex as key where the array has keys for controller and page

@param array $routing contains the routing to be used,
@return $this

Sets up the parameters (usualy from the url) in a logical manner

@param array $params Array containing the parameters
@return $this

Meet Mr. IntentionCache.


Cache class


Function cache. Returns the cache if it is present , exec

@param array | function $func The function to be cached
@param array $params Optional parameters
@param integer $cacheTime Optional cacheTime, determines how long an item should be cached.
@return any $content The result of the function, either cached or 'fresh'

Cache $content using a unique $key for $cacheTime amount of time

@param string $key The unique key for the content
@param any $content The content to be cached
@param int $cacheTime Optional cache duration, if not specified the default will be used

Removes a cache file if it exists.

@param string $key The key of the cache.
@return boolean success Returns true on succes , false on failure.

Meet Mr. IntentionController.


Meet Mr. IntentionDatabase.


Database class , wrapper for PHP PDO


Connects to the database , even though it's using PDO I'm only supporting mysql for now.

@param $host The host to connect with
@param $user The user to connect with
@param $pass The password to connect with
@param $dbname The database name to connect with
@return $this

In case you want to use PDO directly

@return PDO Instance

Facade function , fetches all results for the given sql query

@param String $sql The query to run
@param Array $params Optional, the parameters that goes with the sql
@return array Array containing the results

Inserts a row into the given table

@param string $table The table to insert the data in
@param array $data The data to enter
@return int $id The primary key that resulted from the insert

Quotes a variable so it won 't cause mysql injections

@param mixed $var Variable
@param int $type Type to quote it for, defaults to PDO::PARAM_STR

Updates a row in the given table

@param string $table The table to update the data in
@param array $data The data to update
@param mixed $id Column to check for, for example, the primary key
@param mixed $id_value Value to check on, goes with $id
@return int $id The primary key that resulted from the insert

Fetches a row from the specified table , optionally filtered with specified $key and $value

@param string $table The table to select from
@param array $columns Optional, contains the columns to retrieve, can be skipped
@param string $key Optional, the key to filter on
@param string $value Optional, the value to filter the key on
@return array $result The row from the database

Fetches all rows from the specified table , optionally filtered with specified $key and $value

@param string $table The table to select from
@param array $columns Optional, contains the columns to retrieve, can be skipped
@param string $key Optional, the key to filter on
@param string $value Optional, the value to filter the key on
@return array $result The rows from the database

Meet Mr. IntentionError.


Meet Mr. IntentionLog.


Meet Mr. IntentionLogger.


Meet Mr. IntentionModel.


Model class TODO : Split it up!


Meet Mr. IntentionTest.


Meet Mr. IntentionView.


View class


Renders the given script with optional properties and returns the content.

@method render
@throws {IntentionViewException} If there is no valid file
@param {string} $script The script to render
@param {array} $properties Local properties that will only be available to the script being rendered
@return {string} The content from the script.

Sets a property to be used by the rendered files. Th be magic method __set refers this method

@method set
@param [String] $key The propety name to set
@param [Mixed] $value The value to set it to

Gets the specified property from the locally assigned properties , or if that 's not present, the global property list. If neither are defined , the value of $default is returned The magic method __get refers this method

@method get
@param [String] $key The name of the property to return
@param [Mixed] $default Optional, what to return if the value can not be found, defaults to null
@return [type]

Easy method to create links.

@param string $controller The controller to link to
@param string $action The page to link to
@return string The resulting link