Skip to content

[WIP] Add REST API cookbook entry #4022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cookbook/web_services/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ Web Services
.. toctree::
:maxdepth: 2

rest_api
php_soap_extension
29 changes: 29 additions & 0 deletions cookbook/web_services/rest_api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.. index::
single: Web Services; REST API

How to Create a REST Web Service in a Symfony2 Controller
=========================================================

A REST controller must be able to list, retrieve, create and update a resource.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why a rest controller must be able?this is confusing, it's up to the controller / router what kind of verbs are supportet.

This resource can be anything from a Doctrine entity to a domain object or a network device.

.. note::

There is plenty of way to implement to REST API with Symfony2, we will show you how to implement
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

way -> ways

a simple API with core components but you can also look at `FOSRestBundle`_ if you are looking
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like this approach that is not tied to FOSRestBundle but that goes in detail on the inner components

at building a large API with hypermedia, versionning, automatic routing and more.

Setting up the routing
----------------------

Dealing with response code
--------------------------

Exposing resources in different formats
---------------------------------------

Updating Doctrine entities
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not include any reference to Doctrine.

--------------------------


.. _`FOSRestBundle`: https://github.com/FriendsOfSymfony/FOSRestBundle