conghau/api-resource-bundle

Symfony2 api resource bundle

Installs: 36

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Open Issues: 0

Type:symfony-bundle

1.0.1 2018-10-08 09:15 UTC

This package is not auto-updated.

Last update: 2024-04-23 01:03:54 UTC


README

  • Add config in app\AppKernel
...
   new \TCH\ApiResourceBundle\TCHApiResourceBundle(),
   new \Nelmio\ApiDocBundle\NelmioApiDocBundle(),
   new JMS\SerializerBundle\JMSSerializerBundle($this)

  • Add config in app\config\config.yml
...
jms_serializer:
    metadata:
        auto_detection: true
nelmio_api_doc: ~
tch_api_resource:
   resources:
       user:
           entity: AppBundle\Entity\User
           actions: C.R.U.D.S #Create, Read/Retrieve, Update, Delete, Search
       .......... # add more here
  • Add config in app\config\routing.yml
...
NelmioApiDocBundle:
    resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
    prefix:   /api/doc

tch_api_resource:
    resource: .
    type: tch_api_resource
    prefix:   /api/v1/

Note: See more guide of nelmio here

  • Usage trait class TraitTCHRepository
Example:
    use TCH\ApiResourceBundle\Util\TraitTCHRepository;
    
    /**
     * UserRepository
     *
     * This class was generated by the Doctrine ORM. Add your own custom
     * repository methods below.
     */
    class UserRepository extends \Doctrine\ORM\EntityRepository
    {
        use TraitTCHRepository;
    }

  • Go to api doc
[host]/api/doc

Example: http://127.0.0.1:8000/api/doc

^^ Enjoy