Skip to content

Instantly share code, notes, and snippets.

View tournasdim's full-sized avatar
🎯
Focusing

Tournas Dimitrios tournasdim

🎯
Focusing
View GitHub Profile
<?php
namespace Helloworld\Form;
use Zend\Form\Form;
class SignUp extends Form
{
public function __construct()
{
parent::__construct('signUp');
<?php
namespace Helloworld\Form;
use Zend\Form\Fieldset;
class UserAddressFieldset extends Fieldset
{
public function __construct()
{
parent::__construct('userAddress');
@tournasdim
tournasdim / gist:9996886
Created April 5, 2014 19:30 — forked from michael-romer/gist:3923106
Controller using Form
<?php
namespace Helloworld\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
class IndexController extends AbstractActionController
{
public function indexAction()
@tournasdim
tournasdim / ZF2_Doctrine.php
Created April 3, 2014 05:20
Sample Code to connect to the database with doctrine connection
return array (
'Doctrine' => array (
'Connection' => array (
'Orm_ default ' => array (
'DriverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver' ,
'Params' => array (
'Host' => 'localhost' ,
'Port' => '3306 ' ,
'User' => 'root' ,
'Password' => '' ,
@tournasdim
tournasdim / set_Locale_ZF2.php
Created March 12, 2014 16:36
Defining Locale from module's configuration file in ZF2
// BookList/Module.php (a custom ZF2 module)
public function onBootstrap(MvcEvent $e)
{
$translator = $e->getApplication()->getServiceManager()->get('translator') ;
$translator->setLocale(\Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']))
->setFallbackLocale('en_US') ;
}
@tournasdim
tournasdim / custom_route.php
Created March 2, 2014 09:02
Add a custom route or alias to your ZF1-application . Paste the code into application/bootstrap.php
protected function _initRouter()
{
$frontController = Zend_Controller_Front::getInstance();
$router = $frontController->getRouter();
// Product view route
$route = new Zend_Controller_Router_Route(
'/home',
array(
'controller' => 'index',
@tournasdim
tournasdim / Localization_codes.php
Created February 25, 2014 08:24
The most used localization codes
English, US (en_US)
German, Germany (de_DE)
Chinese, PRC (zh_CN)
Chinese, Taiwan (zh_TW)
Czech, Czech Republic (cs_CZ)
Dutch, Belgium (nl_BE)
Dutch, Netherlands (nl_NL)
English, Australia (en_AU)
English, Britain (en_GB)
English, Canada (en_CA)
@tournasdim
tournasdim / ClassLoader.php
Created February 22, 2014 08:28
A simple ClassLoader (autoloader) with spl_autoload_register function .
/*** nullify any existing autoloads ***/
spl_autoload_register(null, false);
/*** specify extensions that may be loaded ***/
spl_autoload_extensions('.php');
/*** class Loader ***/
function classLoader($class)
{
//$filename = ucfirst(strtolower($class) . '.php') ;
@tournasdim
tournasdim / SPL_LimitIterator.php
Created February 22, 2014 08:22
SPL's LimitIterator , a simple example
$numbers = array(22, 60, 876, 95, 77);
// Initializing the Iterator
$iterator = new ArrayIterator($numbers);
// Pass the converted array to the LimitIterator
$limiter = new LimitIterator($iterator, 0 , 4);
// Loop through the LimitIterator object
foreach ($limiter as $number) {
@tournasdim
tournasdim / SPL_ClassLoader.php
Created February 19, 2014 17:38
SplClassLoader implementation that implements the technical interoperability standards for PHP 5.3 namespaces and class names.
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.