Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to get parameter in Phalcon Micro use Get method

localhost/books/?title=value&pages=value

How to get value title and pages in phalcon micro
in php native i can use

$title = $_GET['title'];
$pages = $_GET['pages'];



48.3k
Accepted
answer
edited Sep '17

https://docs.phalconphp.com/en/latest/Phalcon_Http_Request

public getQuery ([mixed $name], [mixed $filters], [mixed $defaultValue], [mixed $notAllowEmpty], [mixed $noRecursive])

// Returns value from $_GET["id"] without sanitizing
$id = $request->getQuery("id");

// Returns value from $_GET["id"] with sanitizing
$id = $request->getQuery("id", "int");

// Returns value from $_GET["id"] with a default value
$id = $request->getQuery("id", null, 150);
edited Sep '17

You can also use the router to get this, if its something you are always going to get you can do

$router->add('/books/{title}/{pages:[0-9]+}', 'Books::index');

then in your books controller add

public function indexAction($title, $pages) {
    // your code here
}

Documentation: https://docs.phalconphp.com/en/3.2/routing