Symfony2 Bundle for cURL API Calling

The LswApiCallerBundle adds a CURL API caller to your Symfony2 application. It is easy to use from the code and is aimed to have full debugging capabilities. source: Github

With pride we release our 4th Symfony2 bundle: the LswApiCallerBundle. We already got some positive replies from other developers in the Symfony2 community on our other bundles. This bundle adds a debug panel to your Symfony2 where you can find the cURL API calls your application makes. It provides profiling and extensive debugging capabilities to your Symfony2 application. We feel it is an essential bundle if you create an application that does not work with a database, but instead has an API as data store backend.


The bundle supports the following call types:

  • … (and it can easily be extended)

You can find the bundle at:

As always there is a readme documentation on GitHub to get you started.


14 thoughts on “Symfony2 Bundle for cURL API Calling”

  1. Can you please say what i can have in $parameters variable and how can i set curl_opt to HTTP_HEADER for authentification. Ty.

  2. @Marius: Add the “curl_setopt($curl, CURLOPT_HTTPHEADER, …)” call to the public function “makeRequest($curl, $options)”. Hope that works for you.

  3. Is there a way to toggle logging? By default it is always active and our log files grow in an unacceptable way… Any ideas on this?

    Thanks for your time!

  4. @Andy: Yes, we could make it configurable I guess. If you know how to do it, then please do it. I will accept your pull request on Github.

  5. @Kay: Yes, it is for setting Curl options, such as request headers. You do not have to specify the “CURLOPT_” prefix in the option name. These options can also be set in the “Resources/config/services.yml” file. In the end it does something like this:



  6. @Maurits: Thanks for your reply. Is there an easy way to set cookies in the request header? I can’t seem to figure out how, but I need some cookies for authentication. When I don’t need cookies it works like a charm.

  7. I’ve tried to make remote request using that bundle. Result of all requests are: Status: 0 Connection failed.
    If I make request using clean curl, remote server return ‘200 OK’.

    Could you explain the reason.

  8. Eugenio: Thank you for commenting. Are you using HTTPS? Maybe disable “verify_peer” and see what it does.

  9. Hello,

    In my project I have many chained calls (a service calls an API, that internally calls another API, etc). I would have a way to log every call (start, end, params, etc) to debug (especially in production).
    I saw from the code that you already do it for the SF2 profiler bar but I can’t find where the log entries are saved. Also I would be sure that in production the behaviour will be the same (i.e. it depends from the monolog configuration).


  10. I found a solution.
    In my config(_dev).yml I defined a new handler using the api_caller channel:
    type: rotating_file
    path: “%kernel.logs_dir%/api_caller/api_caller.%kernel.environment%.log”
    level: debug
    channels: [api_caller]
    max_files: 10

Leave a Reply

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