Skip to content

Instantly share code, notes, and snippets.

@EuphoryX1
Last active December 12, 2015 07:08
Show Gist options
  • Save EuphoryX1/4734485 to your computer and use it in GitHub Desktop.
Save EuphoryX1/4734485 to your computer and use it in GitHub Desktop.
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.1.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.0.*",
"twig/extensions": "1.0.*@dev",
"symfony/assetic-bundle": "2.1.*",
"symfony/swiftmailer-bundle": "2.1.*",
"symfony/monolog-bundle": "2.1.*",
"sensio/distribution-bundle": "2.1.*",
"sensio/framework-extra-bundle": "2.1.*",
"sensio/generator-bundle": "2.1.*",
"jms/security-extra-bundle": "dev-master",
"jms/di-extra-bundle": "dev-master",
"kriswallsmith/assetic": "1.1.*@dev",
"friendsofsymfony/rest-bundle": "0.11.*@dev",
"jms/serializer": "1.0.*@dev",
"jms/serializer-bundle": "1.0.*@dev"
},
<?php
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new JMS\AopBundle\JMSAopBundle(),
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
new JMS\SerializerBundle\JMSSerializerBundle($this),
new FOS\RestBundle\FOSRestBundle(),
...(snip)
);
// ...(snip)
}
// ...(snip)
}
<?php
namespace Euphory\StoreBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use FOS\RestBundle\View\View;
class UserController extends Controller
{
/**
* @Route("/rest/users", defaults={"_format"="json"})
* @Method({"GET"})
*/
public function allAction()
{
$data = array('users' => array('taro', 'hanako'));
$view = View::create();
$view->setData($data);
return $this->get('fos_rest.view_handler')->handle($view);
}
/**
* @Route("/rest/users/{id}", requirements={"id" = "\d+"}, defaults={"_format"="json"})
* @Method({"GET"})
*/
public function getAction($id)
{
$data = array('user' => 'taro');
$view = View::create();
$view->setData($data);
return $this->get('fos_rest.view_handler')->handle($view);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment