how to fix error Attempted to load class \ "Configuration \" in symfony2? [closed]

2

Good morning. I am trying to integrate the docusign api to sign documents digitally. I'm following the steps for its integration (the steps are here link ), but I'm stuck in the part where I must initialize the configuration, the class already exists in the project (check it already), but even so I get this error:

  

Attempted to load class \ "Configuration \" from namespace   \ "DocuSign \ eSign \". \ NDid you forget to \ "use \" statement.

I already declare use DocuSign\eSign\Configuration; but nothing yet. I do not know what I missed or did not do. Thank you in advance.

    $username = "[USERNAME]";
    $password = "[PASSWORD]";
    $integrator_key = "[INTEGRATOR_KEY]";
    $host = "https://demo.docusign.net/restapi";
    $config = new Configuration(); -> en esta linea me da el fallo
    
asked by devjav 18.08.2016 в 15:56
source

1 answer

1

It is important to define the solution to this problem in a general way. Do it in Symfony 3.2.x

1.- First install the library in autoload. In my case, I added my library in composer.json:

 "Autoload": {
     "Psr-4": {"": "src /"},
     "Classmap": ["app / AppKernel.php", "app / AppCache.php", "** src / AppBundle / juanitourquiza / pagopayphone / library" **]

And after this instruction:

 composer update

2.- Create a service to use the dependency injection within my bundle within the Services folder that you also create so that everything is more ordered with the following code:

//AppBundle/Services/PagotarjetaService.php
<?php
namespace AppBundle\Services;

use BackendBundle\Entity\Reservation;
use AppBundle\juanitourquiza\pagopayphone\library;

class PagotarjetaService{

 public $manager;

 public function __construct($manager) {
        $this->manager = $manager;
 }

 public function implementacion(){
    //tu codigo va aqui
    die("prueba");
 }
}

3.- The following lines should be added in the config.yml:

//app/services.yml
services:
#service_name:
#    class: AppBundle\Directory\ClassName
#    arguments: ['@another_service_name', 'plain_value', '%parameter_name%']

app.pagotarjeta_service:
    class: AppBundle\Services\PagotarjetaService
    arguments: ["@doctrine.orm.entity_manager"]

4.- In the controller that will be used, the service is called

use AppBundle\Services\PagotarjetaService;

5.- Finally we use the service in the controller

$datospago=$this->get('app.pagotarjeta_service');
$datospago->implementacion();

6.- The output for the example will be your code, in this case we put the text test and that will be displayed.

prueba

I hope it helps you, with this this error is corrected and it is the appropriate way to implement it as a service.

Greetings

    
answered by 16.06.2017 в 17:14