I'm using the following route on Phalcon 1.3.0 and PHP 5.4.4:
$router->addGet('/api/:controller/search/{name}',array(
'module'=>'api',
'controller'=>1,
'action'=>'search',
'namespace'=>'MyPhalconModules\Api\Controllers'
));
The URL I'm using is:
http://localhost/phalcon-test/api/task/search/test
In the 'search' action of the 'task' controller I do:
var_dump ($this->dispatcher->getParams());
And the output is mysteriously:
(
[name] => task
)
The expected output would be:
(
[name] => test
)
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Can u provide virtual host config?
This is how I'm setting BaseUrl:
$di['url'] = function () {
$url = new UrlResolver();
$url->setBaseUri('/myPhalconModules/');
return $url;
};
There's no explicit virtual host config though as I'm running MAMP PRO. So localhost just maps to my htdocs folder and inside there I've got the phalcon-test folder. Indexes, Includes and FollowSymLinks are all on as is AllowOverride and Allow form all.
Not sure why Virtual Host would have anything to do with it?
If I use this route from the docs:
$router->add('/:module/:controller/:action/:params', array(
'module' => 1,
'controller' => 2,
'action' => 3,
'params' => 4
));
Then I get:
handler class cannot be loaded
... even though I have a module 'api' containing a controller 'task' with action 'search'.
Ditto with this route:
$router->addGet("/api/task/search/{name}", "Task::search");
This route works but it's static and returns empty params with $dispatcher->getParams():
$router->addGet("/api/task/search/{name}", array(
'module'=>'api',
'controller'=>'task',
'action'=>'search',
'namespace'=>'MyPhalconModules\Api\Controllers'
));
Another mysterious thing is that the INVO tutorial (for example) doesn't seem to have any routes defined and yet it works. Presumably there are some default routes. However, these don't seem to work for a multi-module application.
Found a dynamic route that works:
$router->addGet('/:module/:controller/:action/:params',array(
'module'=>1,
'controller'=>2,
'action'=>3,
'params'=>4,
'namespace'=>'MyPhalconModules\Api\Controllers'
));
Similar to the example from the docs above but defining the 'namespace' key.
You should dump $di->getRouter()->getRoutes(). That will help you understand the 芦default禄 routes (IIRC there is just one).
@geoidesic
I'm closing this issue due to the lack of any reaction. I'll open it again if the need arises
Hi guys.. sorry but I gave up on Phalcon. Just seems impossible to work with since I can't figure out how to debug when the framework is not available as code for inserting debug prods into. It may run fast but seems impossibly slow to develop with as a result.
At the very least you could have done what I've suggested... Almost everything is available to dump, which helps to detect issues. I've fixed some on the bugs myself for minor ones, with pull requests. Since then (was a while back ago on version 2 beta), I didn't have any issue. And as everyone, I do it for free, because I care. So don't say it's impossible without even trying.
@dugwood Quoted you in my bio on Github
Apologies.. it wasn't intended to offend. I was just trying to inform you that I've stopped spending time on Phalcon and why. I'm sure it is possible 鈥撀爃owever I wasn't able to achieve it in the time window I had and with the information available to me at that time... thus "it _seems_ impossibly slow to develop with...".
I do understand. Every CMS needs some time to learn, and if you don't have that time, sometimes it's easier to avoid using one. The thing is that you opened a bug, asked for help, but didn't answer back. I've answered a little bit late (holidays...), spent time on your issue (yeah, just 2 minutes I agree), as @sergeyklay did, and it just ends without feedback.
Anyway, if you want to give it a try for a new project, the code is really great now, and I don't even imagine use another framework/CMS from now on :-)
Most helpful comment
@dugwood Quoted you in my bio on Github