bcosca / fatfree

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!
2.66k stars 446 forks source link

CLI GET options #1078

Closed r3sist closed 6 years ago

r3sist commented 6 years ago

Hi!

I'm trying to write a small cli script, however I couldn't access to cli options via GET.

My simplified code is:

<?php
$f3 = require('lib/base.php');

$f3->route('GET /plan [cli]', function($f3)
{
    echo 'folder: '.$f3->get('GET.folder').PHP_EOL;
});

$f3->run();

If I call php index.php /plan --folder=text

$f3->get('GET.folder') or $f3->get('GET') is empty array, while $f3->get('QUERY') is ok and $f3->get('SERVER') also has the arguments:

[argv] => Array
        (
            [0] => index.php
            [1] => /plan
            [2] => --folder=text
        )

Source: https://fatfreeframework.com/3.6/routing-engine#RoutinginCLImode f3: 3.6.2 php: PHP 7.2.0 (cli) (built: Nov 29 2017 00:14:49) ( NTS MSVC15 (Visual C++ 2017) x86 ) OS: Windows 10

Is it a bug or did I miss something?
Thank you for your help!

xfra35 commented 6 years ago

That's because you're mixing web syntax with shell syntax. It's:

BTW there was a bug with the web syntax: $_GET wasn't populated. Fixed in https://github.com/bcosca/fatfree-core/commit/3e34f37819dfbd85ff8637653e0041f0075e61ec

r3sist commented 6 years ago

Thank you, that / before plan was it