How to fix: You have requested a non-existent service “test.client” with Behat 3

So, it’s been a long day of development.

And the last 50 minutes have been particularly painful.

I’ve been bringing FOSUserBundle, Dunglas API Bundle, Lexik JWT Bundle, and Behat (amongst a good few others) together into one project for the first time.

Most of today has been productive. I’ve solved two of my big headaches, but as the hours have gone by, tiredness has set in.

And rather than call it a night, I did my usual “I’ll just see if I can…” once too many times, and buggered everything up.

If I had been behaving, I could have quickly done a little git bisect magic and found the source of my woes. Alas, I had not been behaving.

Anyway, the issue:

Run bin/behat , encounter error:

Wot do?

Well, there is a major shortage of Google help on this one.

The two most likely answers were not it.

Behat had been working just fine. I knew it was my mistake. But the project is growing and there’s just a ton of possible files that could have changed. When will I learn?

As it turned out, I had changed my  behat.yml file in my tired stupor:

I’d changed  env to a new Symfony Environment I had created so as not to keep messing up my local  dev database every time I re-ran behat.

In my case changing back to  env: "test" solved all my problems.

Ok, well not all of them… plenty of work still to do. But that’s it for this evening.

I hope that saves someone a headache in the future.

Time to commit and go to bed.


Published by

Code Review

Code Review

CodeReviewVideos is a video training site helping software developers learn Symfony faster and easier.

2 thoughts on “How to fix: You have requested a non-existent service “test.client” with Behat 3”

  1. interesting, 🙂

    do you using FOSUserBundle and Dunglas API Bundle together in one project ? I bit confuse about where bundle for create API, FOSUserBundle or DunglasAPIBundle ?

    based on your experience, which should I use ?


    1. Yes, I was using FOSUserBundle and Dunglas API Bundle in the same project.

      FOSUserBundle helps with user management, and the documentation provides examples to do this using the ‘old fashioned’ way – using Twig templates and so on. If unsure on FOSUserBundle in general, please feel free to watch this course.

      DunglasAPIBundle and / or FOSRESTBundle are different approaches to creating a RESTful API with Symfony2.

      Neither DunglasAPIBundle or FOSRESTBundle require you to use FOSUserBundle. You would likely want to use FOSUserBundle if your API had the concept of Users.

      Personally, I am more comfortable using FOSRESTBundle, but DunglasAPIBundle is easier to get started with, in my opinion. However, both require at least an intermediate level of experience with Symfony. I would say that if you have not yet used Symfony for a ‘traditional’ / twig based project, then try it that way first as understanding Symfony is already pretty hard at first, so starting with a REST API as your first build would be extremely difficult, again, in my opinion.

Leave a Reply

Your email address will not be published. Required fields are marked *