A simple, flexible, fast, and security-focused PHP framework
Nephtali documentation

API documentation


Port functions In Nephtali, ports are responsible for validing Get, Post, Cookie, and File inputs.


  • array get(mixed $names, string $key)

    Retrieve an array of the port settings for the ports named in the array. If no second argument is provided, by default the value of the port is returned.

  • void register(string $name, array $opts, mixed $value)

    Register a port for use within pipe functions.

    The $opts argument provides you with several validation and formatting options, all of which are displayed in the example $opts array below:

    $opts = array(
    // minimum length of submitted string
    // a value of zero makes field optional
    'min_length' => 0,
    // maximum length of submitted string
    'max_length' => 5,
    // min value, only applies to FILTER_INT and FILTER_DOUBLE
    'min_value' => 1,
    // min value, only applies to FILTER_INT and FILTER_DOUBLE
    'max_value' => 10000000,
    // automatically decrypts value before performing validation
    'encrypted' => true,
    // allows value to be valid even if no GET or POST variable submitted
    'allow_null' => true,
    // allow array values (e.g, name="buttons[]")
    'allow_array' => true,
    // provide means for 1 or more custom validators
    'validators' => array(
    	'This will be the error message displayed if the validator returns false.'  => function($val)
    		//add your validating code that returns true (valid) or false (invalid)
    // provide opportunity to format value prior to validation
    'formatter' => function($val)
    	//add your formatting code that returns the formatted value
    	return $val;
      // list of valid string values (bool, int, or float types will fail)
      // if a whitelist is set, no other data validation will be performed
      'whitelist' => array('value1','value2')

  • array register_bulk(array $ports, array $values, array $port_names)

    Register multiple ports in one call.

    See n\port\register for a list of valid port options.

    $ports = array(
    	'id' => array(
    		'min_value' => 0,
    		'max_value' => 1000000000
    	'email' => array(
    		'max_length' => 300,
    		'filter' => n\constant\FILTER_EMAIL
    	'token' => array(
    		'max_length' => 200,
    		'filter' => n\constant\FILTER_TEXT
    // manually set value for 'token'
    $values = array(
    	'token' => $_COOKIE['special_token']
    // only register 'id' and 'token' ports contained within $ports array
    $port_names = array('id','token')

  • void register_file(string $name, array $opts, mixed $value)

    Register a file port for use wihtin pipe functions.

  • int signature(array $ports)

    Determine if the array of ports are set on the given page request.

    This is useful if you only want to insert an element if there's no id, or update an element if there is, etc.

  • array validate(array $ports)

    Validate the group of ports named in the array.

Nephtali namespaces