We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Phalcon 4.0.6 Static route BUG

Hello, i got WARNING error for static routes, when i use extra params!

Warning : array_flip(): Can only flip STRING and INTEGER values! in path.to.volt.phtml on line 11 Example:

 * id, title, ident
$categories = Model\Categories::find();

#static route, category is object
foreach ($categories as $category) {
    $router->add('/'.$category->ident, ['category' => $category])->setName('static_route.' . $category->id);

Routes are generated, but with WARNING {{ link_to( [ 'for' : 'static_route.1' ], 'Show Invoice', 'class': 'edit-btn') }}

thanks :)

What php version you use?


7.3.6 and 7.4.0 same result

edited Aug '20

I think this is a php warning - $category here is an object, and you pass it as paths to route. Phalcon does array_flip and that's why you have error https://sandbox.onlinephpfunctions.com/code/da43d8087692128a2979eb704d3d5603279f0f0f as you can check - same error


Solution for routing?

(joke) - turn on error_reporting with E_WARNING flag when application is production model:)

But there is no phalcon bug. You are just passing wrong data.


Wrong data in STATIC ROUTE ?

? I don't understand. Phalcon does array_flip for paths parameter, and you pass there object as value, object cant be a key in php for arrays, so i'm not sure what's your problem here.