We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to get parameter in Phalcon Micro use Get method


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

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

edited Sep '17


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.phalcon.io/en/3.2/routing


As I tried, such Router case doesn't work in Micro.