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