0

I am trying to mock an environment to enable slim3 cli interface.

#!/usr/bin/env php
<?php
array_shift($argv);
$pathInfo = implode('/', $argv);

if (empty($pathinfo)) {
  $pathinfo = '--help';
}
$config = ['environment'=>\Slim\Http\Environment::mock(['REQUEST_URI' => $pathInfo])];
$app = new \Slim\App($config);

$app->get('test:output',function(){
  exit("Arrived!");
});

$app->run();

However when I run the code php bin/run test:example absolutely nothing happens.

If I trap the request and get the request URI it's returned as "/".

Has anyone else had this problem and got round it?

Thanks in advance

James Kipling
  • 121
  • 10

1 Answers1

0

Seems that REQUEST_URI doesn't work without starting /. See this question for details.

Also take a look at Cilex — a special framework for CLI commands, not HTTP routes.

Community
  • 1
  • 1
Alexey Shokov
  • 4,775
  • 1
  • 21
  • 22