-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
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
I followed the doc of 4.2. MicroKernelTrait throws error #10858
Comments
The same error is spotted here Here the solution is creating a service. |
I solved this problem with this code. But I don't know this is correct or not . But now its working. I added the construct() `<?php use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; require DIR . '/vendor/autoload.php'; class Kernel extends BaseKernel
} $kernel = new Kernel('dev', true); |
The issue is the route configuration: protected function configureRoutes(RouteCollectionBuilder $routes)
{
// kernel is a service that points to this class
// optional 3rd argument is the route name
$routes->add('/random/{limit}', 'Kernel::randomNumber');
} The controller resolver does not pick the service from the container but tries to instantiate the @featuriz Can you confirm that changing the route configuration to |
No Its Not working. I have used this in the previous post itself. Yes you are Right. I found that the error is in 2nd argument. It can't find the method in the same file. |
Are you sure? In the previous post you use |
Had the same issue, using kernel in lowercase fixed it for me indeed, both with single and double semicolons. Which one is the preferred solution? I'll make a PR |
Thank you for the confirmation @guillaumesmo! Let's use two colons as we use this notation everywhere else too (I updated my comment above accordingly). |
This PR was merged into the 4.1 branch. Discussion ---------- Update micro_kernel_trait.rst Fixes #10858 this was previously (in 4.0) kernel:randomNumber, it was changed to Kernel::randomNumber but that doesn't work <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/roadmap for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> Commits ------- 337c59c Update micro_kernel_trait.rst
I'm following a doc of symonfy 4.2 MicroKernelTrait
Dated: Jan 10 2019 08:45 AM India ISD.
This causing 2 error.
(1/2) ArgumentCountError
Too few arguments to function Symfony\Component\HttpKernel\Kernel::__construct(), 0 passed in /home/sudhakar/SudhakarK/NB/2019/FZFW/vendor/symfony/http-kernel/Controller/ControllerResolver.php on line 133 and exactly 2 expected
(2/2) InvalidArgumentException
Controller "Kernel" has required constructor arguments and does not exist in the container. Did you forget to define such a service?
How to reproduce:
I followd the turorial of the mentioned page with 4.2 symfony version.
The error is when running http://localhost:8000/random/10
But http://localhost:8000/ works
Thanks.
The text was updated successfully, but these errors were encountered: