PDA

View Full Version : Issues with Symfony2 while parsing the data


LaniSymkowick
10-29-2016, 01:22 AM
Symfony2 is used for making REST API. I am using Liip bundle for all type tests, with conjunction to Alice to create all the necessary fixtures. But, I am facing issues, while testing POST type calls with long JSON data stream is include in the POST data. This is making all the functions unreadable with extreme long lengths.
I am thinking about moving this JSON out of my class and creating YAML files for the current data. In order to parse the data, I will use the Symfony parser.

private function loadYaml($importantasset){
$inputinfo = Yaml::parse(file_get_contents('src/AppBundle/DataFixtures/YAML/' . $importantasset . '.yml'));
return $inputinfo;
}


It is working perfectly, as I can easily convert those back to JSON and try to use those in the main call:

$importantinfo = json_encode($this->loadYaml('myapp'));
$this->client->request(
'POST',
'api location path',
array('important information' => $importantinfo), // Parameters required in the call
array(), // My files
array(),
'body of my data', // Raw data to the function
true
);

Right now, I am looking forward for a simpler method compared to this one. As the job is only to have the data from a stream. Using Faker with this YAML construction is possible or not? I am calling the fixtures, First I will see the function (e.g. <firstname() >. Fixtures will be comprehended with random entities. Using those values with YAML constructions, possible or not?

Solution I have tried:
I have used WebTestCase from Symfony bundle package. It is perfect for testing REST API. Inside the post, data is found inside the body (does not have parameters).

What I am trying to do:
I am a teacher in a local university of Computer Science. Right now, I am assigned a job for making lab assignments for Artificial intelligence class of the 6th semester.
Right now, I am working with an NGO and I am working with data information from it's website to help retired veterans using simple AI algorithms like SVMS and Neural Networks.
Let's say a veteran or active personnel need assistance in a local area and algorithm will assist him to get that. Like, if a person is visiting http://militarybases.co/directory/fort-mccoy-army-base-in-monroe-wi/. This means that he is interested in Moroe base in Wisconsin state and looking for schools, hospitals, rentals or other type of help in that area.
After having the traffic from the website, it will be feed into alogrithm. Which will turn values in the form of probabilistic outputs. I am making a total of 16 assignments with visual using Alice by implementing this 1 big task.