lithium\console\command\Route::show()

public method

Returns the corresponding params for a given URL and an optional request method.

Examples:

1: li3 route show /foo
2: li3 route show post /foo/bar/1
3: li3 route show /test
4: li3 route show /test --env=production

Will return outputs similar to:

1: {"controller":"foo","action":"index"	}
2: {"controller":"foo","action":"bar","args":["1"]}
3: {"controller":"lithium\\test\\Controller","action":"index"}
4: {"controller":"test","action":"index"}

Returns

void

Source

	public function show() {
		$url = join(" ", $this->request->params['args']);
		$method = 'GET';

		if (!$url) {
			$this->error('Please provide a valid URL');
		}

		if (preg_match('/^(GET|POST|PUT|DELETE|HEAD|OPTIONS) (.+)/i', $url, $matches)) {
			$method = strtoupper($matches[1]);
			$url = $matches[2];
		}

		$request = new Request(compact('url') + ['env' => ['REQUEST_METHOD' => $method]]);
		$result = Router::process($request);
		$this->out($result->params ? json_encode($result->params) : "No route found.");
	}