Tag Archive for zend

Zend Router simple extension through simple regex

/**
* Add this in your bootstrap
*/
protected function _initRoutes() {
    
            $ctrl = Zend_Controller_Front::getInstance();
            $router = $ctrl->getRouter();
            //match every call on <a href="http://ZEND_ROOT/aZ2s-Ty9" >http://ZEND_ROOT/aZ2s-Ty9</a>
            $route = new Zend_Controller_Router_Route_Regex('([a-zA-Z0-9]+-[a-zA-Z0-9]+)',
                array(
                    //dispatch this to the VController
                    'controller' => 'v',
                    // iAction()
                    'action'     => 'i'
                    ),
                array(
                    //send the captured value has the "e" parameters of the request
                    1 => 'e'
                    )
            );
    
            //give a name to your route and add it to the default router
            $router->addRoute('view',$route);
        }

source

Mac Address validation on Zend Validate with regex

$validator = new Zend_Validate_Regex('/([a-fA-F0-9]{2}[:|-]?){6}/');
 $valid = $validator->isValid($mac);

source

Zend Framework 1.8 htaccess

SetEnv APPLICATION_ENV development

php_flag magic_quotes_gpc off

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

source

zend amf class

<?

class Tutorials
{
function __construct()
{
# code...
mysql_connect("localhost:8889", "root", "root");
mysql_select_db("information_schema");
}

public function getTutorials(){
$result = mysql_query("SELECT * FROM COLUMNS");
$t = array();

while($row = mysql_fetch_assoc($result)){
array_push($t, $row);
}
return $t;
}
}


?>

source

Zend amf setup

<?
error_reporting(E_ALL|E_STRICT);
ini_set("display_errors", "on");

ini_set("include_path", ini_get("include_path") . ":/Applications/MAMP/frameworks");

require_once 'Zend/Amf/Server.php';
require_once 'Tutorials.php';

$server = new Zend_Amf_Server();
$server->setClass("Tutorials");

echo($server->handle());

?>

source