Skip to content

Instantly share code, notes, and snippets.

View robertbasic's full-sized avatar

Robert Basic robertbasic

View GitHub Profile
These configuration directives can go to the ``config/autoload/{,*.}{global,local}.php`` files, or in the
``module/<module name>/config/module.config.php`` configuration files. The merging of these configuration
files is done by the ``ModuleManager``. It first merges each module's ``module.config.php`` file, and then
the files in ``config/autoload`` (first the ``*.global.php`` and then the ``*.local.php`` files). The order
of the merge is relevant so you can override a module's configuration with your application configuration.
If you have both a ``config/autoload/my.global.config.php`` and ``config/autoload/my.local.config.php``, the
local configuration file overrides the global configuration.
.. warning::
'router' => array(
'routes' => array(
// Literal route named "home"
'home' => array(
'type' => 'literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'Application\Controller\IndexController',
'action' => 'index'
If you are a developer with knowledge of the routing system in Zend Framework 1.x, you should know that some of
the old terminology does not apply in Zend Framework 2.x. In the new routing system we don't have a router as
such, as every route can match and assemble URIs by themselves, which makes them routers, too.
That said, in most cases the developer does not need to worry about this, because Zend Framework 2.x will take
care of this "under the hood". Chances are that the work of the router will done by ``Zend\Mvc\Router\SimpleRouteStack``
or ``Zend\Mvc\Router\Http\TreeRouteStack``.
<?php
namespace Blog\View\Helper;
use Hex\View\Helper\ServiceLocatorAwareHelper;
use Zend\Tag\Cloud as ZendTagCloud;
use Zend\Tag\Cloud\Decorator\HtmlCloud as TagCloudDecorator;
use Zend\Tag\Cloud\Decorator\HtmlTag as TagCloudTag;
@robertbasic
robertbasic / Test.php
Created September 13, 2012 21:19
Chained returns of mocked objects
<?php
/**
* Ad-hoc unit tests for various scenarios reported by users
*/
class Mockery_AdhocTest extends PHPUnit_Framework_TestCase
{
public function setup ()
@robertbasic
robertbasic / Test.php
Created September 13, 2012 20:42
Zend\Db\Adapter\Adapter mocking with mockery
<?php
protected function getAdapterMock()
{
$adapter = m::mock('Zend\Db\Adapter\Adapter');
$platform = m::mock('Zend\Db\Adapter\Platform\Mysql[getName]');
$stmt = m::mock('Zend\Db\Adapter\Driver\Pdo\Statement');
$paramContainer = m::mock('Zend\Db\Adapter\ParameterContainer');
$platform->shouldReceive('getName')
function! NumberToggle()
if(&relativenumber == 1)
set number
else
set relativenumber
endif
endfunc
nnoremap <C-A-n> :call NumberToggle()<cr>
<?php
class Foo {
public function this($param) {
// $this->bar is object Bar
return $this->bar->this($param);
}
public function that($param) {
(gdb)
#0 0x000000d7000000d4 in ?? ()
#1 0x00007fffed261d07 in execute () from /etc/httpd/modules/libphp5.so
#2 0x00007fffed1f4520 in zend_call_function () from /etc/httpd/modules/libphp5.so
#3 0x00007fffed13fdc4 in ?? () from /etc/httpd/modules/libphp5.so
#4 0x00007fffed2a7f62 in ?? () from /etc/httpd/modules/libphp5.so
#5 0x00007fffed261d07 in execute () from /etc/httpd/modules/libphp5.so
#6 0x00007fffed202bde in zend_execute_scripts () from /etc/httpd/modules/libphp5.so
#7 0x00007fffed1a290d in php_execute_script () from /etc/httpd/modules/libphp5.so
#8 0x00007fffed2aa26a in ?? () from /etc/httpd/modules/libphp5.so
10024 execve("/sbin/service", ["service", "httpd", "start"], [/* 27 vars */]) = 0
10024 brk(0) = 0x23fd000
10024 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fcc39ac8000
10024 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
10024 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
10024 fstat(3, {st_mode=S_IFREG|0644, st_size=96707, ...}) = 0
10024 mmap(NULL, 96707, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fcc39ab0000
10024 close(3) = 0
10024 open("/lib64/libtinfo.so.5", O_RDONLY|O_CLOEXEC) = 3
10024 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220\315\0-<\0\0\0"..., 832) = 832