PHP code example of creads / api2symfony-bundle

1. Go to this page and download the library: Download creads/api2symfony-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

creads / api2symfony-bundle example snippets



	

	namespace Acme\DemoBundle\1_0_1_alpha;

	use Symfony\Bundle\FrameworkBundle\Controller\Controller;

	use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
	use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;

	/**
	 * Collection of available post resource
	 *
	 * This is an auto generated class provided by Creads\Api2Symfony PHP library.
	 */
	class PostsController extends Controller
	{
    	/**
	     * Get a list of post
    	 *
	     * @Route("/posts", name="get_posts")
    	 * @Method({"GET"})
	     */
    	public function getPostsAction()
	    {

    	}

	    /**
    	 * Create a new post
	     *
    	 * @Route("/posts", name="post_posts")
	     * @Method({"POST"})
    	 */
	    public function postPostsAction()
    	{

	    }

    	/**
	     * Get a single post
    	 *
	     * @Route("/posts/{id}", name="get_posts_post")
    	 * @Method({"GET"})
	     */
    	public function getPostsPostAction($id)
	    {
    	    return new Response('{"title": "An amazing news"}', 200, array('Content-Type' => 'application/json'));
	    }

	    /**
    	 * Delete a specific post
	     *
    	 * @Route("/posts/{id}", name="delete_posts_post")
	     * @Method({"DELETE"})
    	 */
	    public function deletePostsPostAction($id)
    	{

	    }

	    /**
    	 * Get list of comment for given post
	     *
    	 * @Route("/posts/{id}/comments", name="get_posts_post_comments")
	     * @Method({"GET"})
    	 */
    	public function getPostsPostCommentsAction($id)
	    {

    	}

	    /**
    	 * Comment a post
	     *
    	 * @Route("/posts/{id}/comments", name="post_posts_post_comments")
	     * @Method({"POST"})
    	 */
	    public function postPostsPostCommentsAction($id)
    	{

	    }
	}