slimphp / Slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
http://slimframework.com
MIT License
11.98k stars 1.95k forks source link

Few issues regarding CallableResolver class. #1371

Closed ConstantineYurevich closed 9 years ago

ConstantineYurevich commented 9 years ago

There are actually 2 related issues connected to CallableResolver class.

  1. Very strange, that callbackResolver supports only "xxx:xxx" format.

Suppose I have following container:

$c['callableAction'] = function($c) {
   return new MyInvokableClass();
}
class MyInvokableClass 
{
   public function __invoke()
   {
      //do something
   }
}

When I try to use it in route - it tells me, that "callableAction is not resolvable":

$app->get('/test', 'callableAction');

This way I'm not able to use callableResolver to resolve invokable classes from my container. This classes are quite useful if you use Action-Domain-Responder (with one action per class) pattern instead of Model-View-Controller.

  1. Another issue is that sometimes people may need to use their custom resolvers. It is great, that I can replace standard resolver using DI, but I would really like to extend existing resolver with few lines of my custom functionality.

Question: why did you make this class final? :)

akrabat commented 9 years ago

CallableResolver supports one format. If you need another, then you can replace the default implementation with your own choice. Given that CallableResolver has a mere 63 lines of PHP code in it, it's not hard to replace…

See http://ocramius.github.io/blog/when-to-declare-classes-final/ for question 2.

ConstantineYurevich commented 9 years ago

Ok, thanks.