We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

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


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.