wwsh / gastro-api
Maintained Gastro API for desktop and mobile apps
Requires
- php: >=5.4
- doctrine/doctrine-bundle: >=1.4
- doctrine/orm: ~2.5,>=2.2.3
- friendsofsymfony/rest-bundle: 1.7.7
- incenteev/composer-parameter-handler: ~2.1
- jms/di-extra-bundle: 1.*
- jms/security-extra-bundle: ^1.5
- jms/serializer-bundle: ^1.1
- knplabs/knp-snappy-bundle: ^1.2
- nelmio/api-doc-bundle: ^2.11
- qandidate/symfony-json-request-transformer: 1.*
- sensio/distribution-bundle: *
- sensio/framework-extra-bundle: 3.*
- symfony/monolog-bundle: >=2.7
- symfony/symfony: >=2.8
- twig/extensions: ~1.2
Requires (Dev)
- mockery/mockery: *
- phpspec/phpspec: ~2.0
This package is not auto-updated.
Last update: 2025-01-04 20:36:43 UTC
README
This bundle supports Gastro API's functionality, specified and used by desktop and mobile apps, written by wwsh.
For more information contact Thomas Parys at this site.
Configuration
Enable Doctrine ORM in your mail config.yml and add the configuration for FOSRestBundle, listed below:
fos_rest:
param_fetcher_listener: true
body_listener: true
body_converter:
enabled: true
format_listener:
rules:
- { path: '^/api', priorities: [ json ], fallback_format: json, prefer_extension: true }
- { path: '^/', priorities: [html, json], fallback_format: html, prefer_extension: false }
view:
view_response_listener: 'true'
mime_types: ['application/json', 'application/json;version=1.0', 'application/json;version=1.1']
formats:
json: true
html: false
xml: false
routing_loader:
default_format: json
include_format: false
exception:
codes:
'Symfony\Component\Routing\Exception\ResourceNotFoundException': 404
'Doctrine\ORM\OptimisticLockException': HTTP_CONFLICT
messages:
'Symfony\Component\Routing\Exception\ResourceNotFoundException': true
access_denied_listener:
json: true
Don't forget to enable these bundles in the kernel:
new \FOS\RestBundle\FOSRestBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(),
new \Nelmio\ApiDocBundle\NelmioApiDocBundle(),
new \Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
Now it's time to include the routes in your routing.yml:
api:
resource: "@ApiBundle/Resources/config/routing.yml"
type: rest
prefix: /api
You can customize your prefix, but I am recommending to use the standard one.
Now the api should be set. To create the database schema and fill with example data, you can use:
php bin/console database:create
php bin/console doctrine:schema:create
php bin/console doctrine:fixtures:load
See if your API is working here: API DOC
On any questions, feel free to ask.