We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
As title indicates, i am wondering whther it is possible to create a method like
`$app->register('abc', function($a, $b) {
return $a."<br>".$b;
});`
and then use it like echo $app->abc("hello", "xxx");
echo $app->abc("hello", "xxx");
Thanks.
The text was updated successfully, but these errors were encountered:
No, but it is really easy to do yourself.
// "MyProject/MyApp.php" namespace MyProject; use Klein\Exceptions\DuplicateServiceException; class MyApp extends \Klein\App { public function factory($name, $closure) { if (isset($this->services[$name])) { throw new DuplicateServiceException('A service is already registered under '. $name); } $this->services[$name] = $closure; } }
Now use the instance of your class instead:
$myApp = new MyProject\MyApp(); $klein = new Klein\Klein(null, $myApp); $app = $klein->app(); $app->factory('abc', function ($a, $b) { return $a . '<br>' . $b; }); echo $app->abc('hello', 'xxx');
Sorry, something went wrong.
No branches or pull requests
As title indicates, i am wondering whther it is possible to create a method like
`$app->register('abc', function($a, $b) {
});`
and then use it like
echo $app->abc("hello", "xxx");
Thanks.
The text was updated successfully, but these errors were encountered: