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

Micro application - cannot get started

Hello there,

I'm completely new to Phalcon and I'm stuck at the Micro application tutorial. Here's the code so far:

<?php
# public/index.php

use Phalcon\Mvc\Micro;
$app = new Micro();

$app->get('/{name}', function ($name) {
    var_dump(func_get_args());
    die;
});

$app->handle();

Now if I

$ cd public
$ php -S localhost:8006

And go to https://localhost:8006/foo, here's what I get:

array(1) { [0]=> string(0) "" }

So basically $name is an empty string instead of foo.

What's wrong with this?

PHP 7.1 - Phalcon 3.2.2

Thank you, Ben

edited Oct '17

It's about your nginx/apache config which you didn't provide. Oh wait, there is no apache/nginx. Well then try:

$app = new Micro();
$app->getRouter()->setUriSource(Router::URI_SOURCE_SERVER_REQUEST_URI)

Brilliant.

Why not auto detecting that php_sapi_name() == cli-server?

Thank you for your quick reply!

Ben