04.
GET one Programmer
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Whoops, an error! Please, try again later.
6 Comments
in showAction($nickname), when I try to get a programmer from the repository, PhpStorm does not auto Complete finOneByNickName(). It only shows the 4 default methods. I am working with the project files and the function is present in ProgrammerRepository.
/**
* @Route("/api/programmers/{nickname}")
* @Method("GET")
*/
public function showAction($nickname)
{
$programmer = $this->getDoctrine()
->getRepository('AppBundle:Programmer')->findOneBy(array(''))
->find__________
;
$data = array(
'nickname' => $programmer->getNickName(),
'avatarNumber' => $programmer->getAvatarNumber(),
'powerLevel' => $programmer->getPowerLevel(),
'tagLine' => $programmer->getTagLine(),
);
return new Response(json_encode($data));
}
Any suggestions on where i am going wrong?
---------------------------------------------
P.s. previously output works fine.
/d/wamp/www/symfony-rest $ php testing.php
HTTP/1.1 200 OK
Host: localhost:8000
Connection: close
X-Powered-By: PHP/5.5.12
Cache-Control: no-cache
Date: Fri, 02 Dec 2016 08:06:02 GMT
Content-Type: text/html; charset=UTF-8
X-Debug-Token: b8529d
X-Debug-Token-Link: /_profiler/b8529d
Hi ObjectOrienter699
Hey Zuhayer,
I suppose you have already installed and enabled Symfony plugin for PhpStorm, right?
I see an error in your code, you need to call findOneByNickName() right after getRepository(), i.e. get rid of findOneBy(array('')) method in your call chain. The correct code is:
Does it help you?
Cheers!
I had installed the PhpStorm plugin, but forgot to Enable it. Thanks a bunch for the help.
Error in code was copy/paste error on my part.
Great! I'm glad it works now ;)
Cheers!
Hi , I have a problem starting with this course.
I downloaded the course from chapter 4 but I can't make it run .
When I run `php testing.php` I get the following error:
`Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 3: <url> malformed (see http://curl.haxx.se/libcurl... in C:\..\..\..\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.
php:187
Stack trace:
#0 C:\..\..\..\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(150): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array)
#1 C:\..\..\..\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(103): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleH
ttp\Handler\CurlFactory))
#2 C:\..\..\..\vendor\guzzlehttp\guzzle\src\Handler\CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Ha
ndler\CurlFactory))
#3 C:\..\..\..\vendor\guzzlehttp\guzzle\src\Handler\Proxy.php(28): GuzzleHttp\Handle in C:\..\..\..\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 187`
Hey Karolos
That error means that something in the URL was not properly formatted
Can you show me how your testing.php file looks like ?
Have a nice day!
"Houston: no signs of life"
Start the conversation!