To generate a WSDL file in Symfony using the NelmioApiDocBundle, you can follow these steps:


Step 1: Install the NelmioApiDocBundle

Ensure you have the NelmioApiDocBundle installed in your Symfony project. If not, you can install it using Composer:

$ composer require nelmio/api-doc-bundle


Step 2: Configure the Bundle
Open the config/bundles.php file and add the following line to enable the NelmioApiDocBundle:

Nelmio\ApiDocBundle\NelmioApiDocBundle::class => ['all' => true],

Step 3: Annotate your API endpoints

In your Symfony controllers, use annotations to define your API endpoints. The NelmioApiDocBundle will parse these annotations and generate the WSDL file.

For example, let's assume you have a UserController with an API endpoint to retrieve user information:

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Nelmio\ApiDocBundle\Annotation\Model;
use Nelmio\ApiDocBundle\Annotation\Operation;
use Nelmio\ApiDocBundle\Annotation\Response;
use Nelmio\ApiDocBundle\Annotation\Security;

class UserController extends AbstractController
     * @Route("/user/{id}", methods={"GET"})
     * @Operation(
     *     summary="Get user information",
     *     @Response(
     *         response=200,
     *         description="User information",
     *         @Model(type=User::class)
     *     ),
     *     @Security(name="Bearer")
     * )
    public function getUser($id)
        // Your logic to retrieve user information


Step 4: Generate the WSDL file
Run the following command in your terminal to generate the WSDL file:

$ php bin/console api:swagger:export --format=wsdl --yaml

This command will generate the WSDL file based on the annotated API endpoints in your Symfony project.


Step 5: Access the WSDL file

Once the WSDL file is generated, it will be available at the following URL:


Replace your-project-url with the base URL of your Symfony application.


That's it! The NelmioApiDocBundle will automatically parse your annotated API endpoints and generate the corresponding WSDL file. You can further customize the annotations and configuration to suit your specific needs.