Skip to main content

Posts

Showing posts from April, 2015

How to configure zf2 and doctrine2 ?

Step-1 : install zf2 developer tool  php composer.pharrequire zendframework/zend-developer-tools:dev-master Step-2: add in application config/application.config.php 'modules' => array( 'ZendDeveloperTools', 'DoctrineModule', 'DoctrineORMModule', 'Application', ), Step-3: Create your entity module/Application/src/Application/Entity/User namespace Application\Entity; use Doctrine\ORM\Mapping as ORM; /** @ORM\Entity */ class User { /** * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") * @ORM\Column(type="integer") */ protected $id; /** @ORM\Column(type="string") */ protected $fullName; // getters/setters } Step-4: do mapping in module/Application/config/module.config.php 'doctrine' => array( 'driver' => array( 'application_entities' => array( 'class' =>'Doctrine\ORM

How to create navigation in ZF2 with partial template

Step -1 : Create partial template location : Application/view/partial/navigation.phtml in navigation.phtml file put your custome html  code. like <ul class="sidebar-menu"> <li class="header">MAIN NAVIGATION</li> <?php $count = 0 ?> <?php foreach ($this->container as $page): ?> <?php /* @var $page Zend\Navigation\Page\Mvc */ ?> <?php // when using partials we need to manually check for ACL conditions ?> <?php if( ! $page->isVisible() || !$this->navigation()->accept($page)) continue; ?> <?php $hasChildren = $page->hasPages() ?> <?php if( ! $hasChildren): ?> <li <?php if($page->isActive()) echo 'class="active treeview"'?>> <a class="nav-header" href="<?php echo $page->getHref() ?>"> <i class="fa fa-dashboard"></i><span> <?php echo $this->translate

How to change layout of zfcUser for login and registration ?

in modul.php public function onBootstrap(MvcEvent $e) { $eventManager = $e->getApplication()->getEventManager(); $moduleRouteListener = new ModuleRouteListener(); $moduleRouteListener->attach($eventManager); $application = $e->getTarget(); $sm = $application->getServiceManager(); $auth = $sm->get('zfcuser_auth_service'); if (!$auth->hasIdentity()) { $eventManager = $e->getApplication()->getEventManager(); $eventManager->attach(MvcEvent::EVENT_DISPATCH, function($e) { $vm = $e->getViewModel(); $vm->setTemplate('layout/layout-cutome'); }); } }

How to change layout and template of error Page in zf2

You can do this by help of module.php  public function onBootstrap ( EventInterface $event ) { $eventManager -> getSharedManager() -> attach( ' * ' , MvcEvent :: EVENT_DISPATCH , array ( $this , ' onDispatchError ' ), - 100 ); $eventManager -> getSharedManager() -> attach( ' * ' , MvcEvent :: EVENT_DISPATCH_ERROR , array ( $this , ' onDispatchError ' ), - 100 ); $eventManager -> getSharedManager() -> attach( ' * ' , MvcEvent :: EVENT_RENDER_ERROR , array ( $this , ' onDispatchError ' ), - 100 ); } public function onDispatchError ( MvcEvent $event ){ $response = $event -> getResponse(); if ( $response -> getStatusCode() == 404 ) { $vm = $ event -> getViewModel(); $vm -> setTemplate( ' layout/custom_404 ' ); //DO SOMETHING $event -> getViewM

How to Setup Zfcuser , ZfcUserDoctrineORM , BjyAuthorize in ZF2

STEP 1 : Install All module by composer . file name composer.json  {     "name": "zendframework/skeleton-application",     "description": "Skeleton Application for ZF2",     "license": "BSD-3-Clause",     "keywords": [         "framework",         "zf2"     ],     "homepage": "http://framework.zend.com/",     "require": {         "php": ">=5.3.3",         "zendframework/zendframework": "~2.3",         "doctrine/doctrine-orm-module": "0.7.*",         "zf-commons/zfc-user": "~0.1",         "bjyoungblood/bjy-authorize": "~1.1",         "zf-commons/zfc-user-doctrine-orm": "~0.1"     } } run in terminal : " composer   update" or " composer . phar update" STEP-2:  Database details  file : config/autoload/doctrine.loca