के साथ काम करने में असमर्थ मैं एक REST ढांचे के साथ आने के लिए Symfony2 और FOSRestBundle का उपयोग करने की कोशिश कर रहा हूं और मैं बुरी तरह विफल रहा हूं।FOSRestBundle
मैं निम्नलिखित किया है:
मेरी deps फ़ाइल में:
[FOSRest]
git=git://github.com/FriendsOfSymfony/FOSRest.git
target=fos/FOS/Rest
[FOSRestBundle]
git=git://github.com/FriendsOfSymfony/FOSRestBundle.git
target=bundles/FOS/RestBundle
[JMSSerializerBundle]
git=git://github.com/schmittjoh/JMSSerializerBundle.git
target=bundles/JMS/SerializerBundle
मेरी क्षुधा में/config.yml
fos_rest:
view:
formats:
rss: true
xml: false
templating_formats:
html: true
force_redirects:
html: true
failed_validation: HTTP_BAD_REQUEST
default_engine: twig
sensio_framework_extra:
view:
annotations: false
मेरी नियंत्रक में:
namespace Rest\WebServiceBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use FOS\RestBundle\View\View;
class DefaultController extends Controller
{
public function indexAction($name)
{
$view = View::create()
->setStatusCode(200)
->setData($name);
return $this->get('fos_rest.view_handler')->handle($view);
}
}
जब मैं यूआरएल पर जाता हूं: http://local.symfony.com/web/app_dev.php/hello/test
मैं:
Unable to find template "".
500 Internal Server Error - InvalidArgumentException
2 linked Exceptions: Twig_Error_Loader » Twig_Error_Loader
प्रलेखन मेरे लिए भ्रामक लगता है और मैं जारी करने में असमर्थ हूँ। मैं चाहता हूं कि नियंत्रक को डेटा की एक सरणी पास कर सकें और एक JSON प्रारूप वापस प्राप्त कर सकें। क्या कोई मदद कर सकता है?
मुझे यह भी मिलने में परेशानी हो रही है। अपेक्षाकृत सरल कार्य की तरह लगता है कि यह काफी भ्रमित लगता है। क्या आपके पास कोई भाग्य है? – greg