Yii 2 - Call_User_Func Warrning

When I try run app on linux server with php version: 5.4.23 I have a warrning:

"call_user_func() expects parameter 1 to be a valid callback, no array or string given"

and my app doesn’t work

On windows and php v 5.4.22 it works correct

Any suggestion ?

what code are you referring to? Please post the code or say which file and line of the framework you refer to.




1. in vendor/yiisoft/yii2/base/Component.php at line 546

537538539540541542543544545546547548549550551552553554555


                $event = new Event;

            }

            if ($event->sender === null) {

                $event->sender = $this;

            }

            $event->handled = false;

            $event->name = $name;

            foreach ($this->_events[$name] as $handler) {

                $event->data = $handler[1];

                call_user_func($handler[0], $event);

                // stop further handling if the event is handled

                if ($event->handled) {

                    return;

                }

            }

        }

        // invoke class-level attached handlers

        Event::trigger($this, $name, $event);

    }




so this looks like you regsistered an invalid event handler.

I din’t register any own event. In stack trace I see:

Stack trace:


#0 [internal function]: yii\base\ErrorHandler->handleError(2, 'call_user_func(...', '/home/th175382/...', 546, Array)

#1 vendor/yiisoft/yii2/base/Component.php(546): call_user_func(NULL, Object(yii\base\Event))

#2 vendor/yiisoft/yii2/base/Application.php(350): yii\base\Component->trigger('beforeRequest')

I don’t understand why it’s work on my local machine, a don’t on the remote :(

There must be something that registered an handler to the beforeRequest event. If it was not yourself it may be some extension or an application behavior.

Can you show your composer.json file and the application config?

Yes, composer is stndard yii advance template


{

	"name": "yiisoft/yii2-app-advanced",

	"description": "Yii 2 Advanced Application Template",

	"keywords": ["yii2", "framework", "advanced", "application template"],

	"homepage": "http://www.yiiframework.com/",

	"type": "project",

	"license": "BSD-3-Clause",

	"support": {

		"issues": "https://github.com/yiisoft/yii2/issues?state=open",

		"forum": "http://www.yiiframework.com/forum/",

		"wiki": "http://www.yiiframework.com/wiki/",

		"irc": "irc://irc.freenode.net/yii",

		"source": "https://github.com/yiisoft/yii2"

	},

	"minimum-stability": "beta",

	"require": {

		"php": ">=5.4.0",

		"yiisoft/yii2": "*",

		"yiisoft/yii2-bootstrap": "*",

		"yiisoft/yii2-swiftmailer": "*"

	},

	"require-dev": {

		"yiisoft/yii2-codeception": "*",

		"yiisoft/yii2-debug": "*",

		"yiisoft/yii2-gii": "*"

	},

	"suggest": {

		"codeception/codeception": "Codeception, 1.8.*@dev is currently works well with Yii.",

		"codeception/specify": "BDD style code blocks for PHPUnit and Codeception",

		"codeception/verify": "BDD Assertions for PHPUnit and Codeception",

		"yiisoft/yii2-faker": "Fixtures generator for Yii2 based on Faker lib"

	},

	"scripts": {

		"post-create-project-cmd": [

			"yii\\composer\\Installer::setPermission"

		]

	},

	"config": {

		"process-timeout": 1800

	},

	"extra": {

		"writable": [

			"backend/runtime",

			"backend/web/assets",


			"console/runtime",

			"console/migrations",


			"frontend/runtime",

			"frontend/web/assets"

		]

	}

}



Config main:


<?php

$params = array_merge(

    require(__DIR__ . '/../../common/config/params.php'),

    require(__DIR__ . '/../../common/config/params-local.php'),

    require(__DIR__ . '/params.php'),

    require(__DIR__ . '/params-local.php')

);


return [

    'id' => 'app-admin',

    'basePath' => dirname(__DIR__),

    'controllerNamespace' => 'admin\controllers',

    'language' => 'pl-PL', // ← here!

    'bootstrap' => ['log'],

    'modules' => [],

    'components' => [

        'user' => [

            'identityClass' => 'common\models\User',

            'enableAutoLogin' => true,

        ],

        'log' => [

            'traceLevel' => YII_DEBUG ? 3 : 0,

            'targets' => [

                [

                    'class' => 'yii\log\FileTarget',

                    'levels' => ['error', 'warning'],

                ],

            ],

        ],

        'errorHandler' => [

            'errorAction' => 'site/error',

        ],

    ],

    'params' => $params,

];

config main-local


<?php


$config = [];


if (!YII_ENV_TEST) {

    // configuration adjustments for 'dev' environment

    $config['bootstrap'][] = 'debug';

    $config['modules']['debug'] = 'yii\debug\Module';

    $config['modules']['gii'] = 'yii\gii\Module';

}


return $config;



does the problem also exist with a fresh install of the advanced app without any changes?

yes I install fresh php


composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced /path/to/yii-application

and it’s the same error.

I use composer on my local machine and then move files via ftp, does it matter ? I should use composer on remote server ? (I don’t permission to console )

In Yii requirements I have:

PDO SQLite extension - warning

Memcache extension - warning

APC extension - warning

Expose PHP - warning

ON localhost:

I have only APC extension - warning

Can it be the reason ?

No idea what is going wrong here. Seen that there is a similar issue report on github. Please provide more information(Operating system and exact version) in that issue: https://github.com/yiisoft/yii2/issues/1988