jenssegers / lean

Use the PHP League's Container package with auto-wiring support as the core container in Slim 3
31 stars 5 forks source link

Example not working #3

Closed bladeofsteel closed 6 years ago

bladeofsteel commented 6 years ago

I'm try use this project but I got exception in example.

In empty folder I install slim & lean:

composer require slim/slim "^3.0"
composer require jenssegers/lean

next I make index.php:

<?php
require 'vendor/autoload.php';

$app = new Jenssegers\Lean\App();
$app->get('/hello/{name}', function ($request, $response, $args) {
    return $response->getBody()->write("Hello, " . $args['name']);
});

$app->run();

start build-in web-server:

php -S localhost:8000

and go to http://localhost:8000/hello/world in console I got stack trace:

[Sun Feb  4 13:00:05 2018] Slim Application Error:
Type: League\Container\Exception\NotFoundException
Message: Unable to resolve a value for parameter (request) in the function/method (__invoke)
File: /Users/oleg/projects/self/slim/vendor/league/container/src/Argument/ArgumentResolverTrait.php
Line: 68
Trace: #0 [internal function]: League\Container\ReflectionContainer->League\Container\Argument\{closure}(Object(ReflectionParameter))
#1 /Users/oleg/projects/self/slim/vendor/league/container/src/Argument/ArgumentResolverTrait.php(73): array_map(Object(Closure), Array)
#2 /Users/oleg/projects/self/slim/vendor/league/container/src/ReflectionContainer.php(80): League\Container\ReflectionContainer->reflectArguments(Object(ReflectionMethod), Array)
#3 /Users/oleg/projects/self/slim/vendor/league/container/src/Container.php(211): League\Container\ReflectionContainer->call(Object(Closure), Array)
#4 /Users/oleg/projects/self/slim/vendor/jenssegers/lean/src/Lean/Strategies/AutoWiringStrategy.php(42): League\Container\Container->call(Object(Closure), Array)
#5 /Users/oleg/projects/self/slim/vendor/slim/slim/Slim/Route.php(335): Jenssegers\Lean\Strategies\AutoWiringStrategy->__invoke(Object(Closure), Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#6 /Users/oleg/projects/self/slim/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\Route->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#7 /Users/oleg/projects/self/slim/vendor/slim/slim/Slim/Route.php(313): Slim\Route->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#8 /Users/oleg/projects/self/slim/vendor/slim/slim/Slim/App.php(495): Slim\Route->run(Object(Slim\Http\Request), Object(Slim\Http\Response))
#9 /Users/oleg/projects/self/slim/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\App->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#10 /Users/oleg/projects/self/slim/vendor/slim/slim/Slim/App.php(388): Slim\App->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#11 /Users/oleg/projects/self/slim/vendor/slim/slim/Slim/App.php(296): Slim\App->process(Object(Slim\Http\Request), Object(Slim\Http\Response))
#12 /Users/oleg/projects/self/slim/index.php(16): Slim\App->run()
#13 {main}

If I replace LeanApp by SlimApp application work well

bladeofsteel commented 6 years ago

current versions:

container-interop/container-interop 1.2.0
jenssegers/lean                     v0.2.2
league/container                    2.4.1
nikic/fast-route                    v1.2.0
pimple/pimple                       v3.2.3
psr/container                       1.0.0
psr/http-message                    1.0.1
slim/slim                           3.9.2