Undefined index: role_id at BjyAuthorize


Strange error around here:

 PHP Notice:  Undefined index: role_id in /var/www/site/vendor/bjyoungblood/bjy-authorize/src/BjyAuthorize/Provider/Role/ZendDb.php on line 90


It seems that SQL script creates user_role table with userId field but, at php module is requested role_id… just change column name and it’s fine!

Hope it helps!

Zend Framework 2: Use Different Layout Templates for each module


Hi there! Having different modules (like: default application module and CustomModule1) I had trouble setting different html layouts to them!

The solution is edit your module’s bootstrap like this:

public function onBootstrap(MvcEvent $e)
// You may not need to do this if you’re doing it elsewhere in your
// application
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();

$sharedEventManager = $eventManager->getSharedManager(); // The shared event manager
$sharedEventManager->attach(__NAMESPACE__, MvcEvent::EVENT_DISPATCH, function ($e) {
$controller = $e->getTarget(); // The controller which is dispatched
$controllerName = $controller->getEvent()
if (!in_array($controllerName,
) {

please do not forget to include the template at templates path at module.config.php

‘view_manager’ => array(
‘template_map’=> array(
‘layout/layoutadm’ => __DIR__ . ‘/../view/layout/layoutadm.phtml’,

Hope it helps!

Quick Tips: Doctrine 2 useful commands


Hi there! Using Zend Framework 2 With doctrine have been nice! But commands for update and validate schema are hard to keep it in mind! So on Root Dir:

Validate Schema: 

./vendor/bin/doctrine-module orm:validate-schema

Create Schema:

./vendor/bin/doctrine-module orm:schema-tool:create

Validate an Update:

./vendor/bin/doctrine-module orm:schema-tool:update –dump-sql

Apply an Update:

./vendor/bin/doctrine-module orm:schema-tool:update –force

Hope It helps some one!

Don’t forget to leave a comment!

MySQL select to file


So, the idea is to execute a query in MySQL but export the result to a CSV file.
MySQL gives you the statement INTO OUTFILE

Select * from table_name into outfile ‘/path/to/file.csv

Hope it helps.