I'm trying to use the JMSSerializerBuilder
to encode my objects in json to be able to make AJAX calls.
I've succesfully installed the bundle through composer.
Then, following the official documentation, I'm doing:
<?php
namespace Pondip\GeolocBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use JMS\Serializer\SerializerBuilder;
class DefaultController extends Controller
{
public function getLakesSurroundingAction($lat=0, $lng=0, $limit = 50, $distance = 50, $unit = 'km')
{
$lakesNearby= $this->getNearby($lat, $lng, $limit, $distance, $unit);
$serializer = JMS\Serializer\SerializerBuilder::create()->build();
$return = $serializer->serialize($return, 'json');
}
}
But it returns
FatalErrorException:
Error: Class 'Pondip\GeolocBundle\Controller\JMS\Serializer\SerializerBuilder' not found in C:\Program Files (x86)\wamp\www\Pondip Dev\src\Pondip\GeolocBundle\Controller\DefaultController.php line 51
line 51 is:
$serializer = JMS\Serializer\SerializerBuilder::create()->build();
Why is that happening?
When removing the use JMS\Serializer\SerializerBuilder;
line (since it is not specified in the doc) I just get an internal server error.