Closed JefferyWong closed 8 years ago
I checked https://akrabat.com/a-slim3-skeleton/ again Do I have to add every Action class file to dependencies.php like HomeAction?
I have the same problem.
Fixed with adding it to dependencies.php
@JefferyWong The default is to pass the container to the action. That's not ideal as you're passing in a generic DI container and not declaring your dependencies. So no, you don't HAVE to add every action in dependencies.php
, but it's better that you do, and declare your action's dependencies in the constructor
I create a new Class in app/src/Action which namespace is App\Action too. And use exactly the same constructor with HomeAction . I use it in route file but got next error: Catchable fatal error: Argument 1 passed to App\Action\ProductAction::__construct() must be an instance of Slim\Views\Twig, instance of Slim\Container given, called in /Users/tinker010/zhengjie/kafe/vendor/slim/slim/Slim/CallableResolver.php on line 64 and defined in /Users/tinker010/zhengjie/kafe/app/src/Action/ProductAction.php on line 21
Don't know why, here is my New Class: <?php namespace App\Action;
use Slim\Views\Twig; use Psr\Log\LoggerInterface; use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ResponseInterface as Response; use Httpful\Request as Rest; use Httpful\Mime; use Eventviva\ImageResize;
final class ProductAction { private $view; private $logger;
}