flightphp / core

An extensible micro-framework for PHP
https://docs.flightphp.com
MIT License
2.63k stars 409 forks source link

code reduction with parameters #443

Closed oscarlosan closed 8 months ago

oscarlosan commented 3 years ago
class Greeting {
    public static function hello($params) {
        echo 'hello '.$params['planet'].'!';
    }
}

//it would be interesting to be able to pass parameters. It would reduce my code by 30%. All in the same line:

Flight::route('/', array('Greeting','hello', ['planet' => 'Earth']));

paxperscientiam commented 2 years ago

Perhaps you could try overriding the router. See here: https://flightphp.com/learn#overriding

masroore commented 2 years ago

If your controller methods need static parameters, then you may rethink your code design. The default router is optimized for capturing user-supplied dynamic inputs.

n0nag0n commented 8 months ago

If your controller methods need static parameters, then you may rethink your code design. The default router is optimized for capturing user-supplied dynamic inputs.

I agree, I think that this isn't the way to go with the framework moving forward, but appreciate the feedback! Overriding is probably your best bet.