conghau / api-resource-bundle
Symfony2 api resource bundle
Installs: 36
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.0
- jms/serializer-bundle: ^0.13|^1.0|^2.0.0
- nelmio/api-doc-bundle: ^2.13.0
- pagerfanta/pagerfanta: v1.0.4
Requires (Dev)
- doctrine/doctrine-bundle: 1.6.4
- doctrine/orm: v2.5.5
- phpunit/phpunit: 5.2.*
- sensio/framework-extra-bundle: ^3.0
- symfony/framework-bundle: ^2.8
- symfony/monolog-bundle: 2.12.0
This package is not auto-updated.
Last update: 2025-03-25 05:32:29 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