sajad torkamani

Create project

You have two options for creating a new API platform project.

1. Use the official distribution

Download the latest .tar.gz release from Github.

Download and build the latest versions of the Docker images:

docker-compose build --pull --no-cache

Make sure no processes are using ports 80, 443, and 5432, and then start Docker Compose in detached mode:

docker-compose up -d

See this post on how to kill processes using those ports.

2. Install in a Symfony application

Create Symfony project
symfony new <project>
Install API Platform recipe

Install the API Platform Symfony Flex recipe:

symfony composer req api

This will create a bunch of files and directories:

 config/packages/api_platform.yaml
 config/packages/doctrine.yaml
 config/packages/doctrine_migrations.yaml
 config/packages/nelmio_cors.yaml
 config/packages/security.yaml
 config/packages/twig.yaml
 config/packages/validator.yaml
 config/routes/api_platform.yaml
 docker-compose.override.yml
 docker-compose.yml
 migrations/
 src/Entity/
 src/Repository/
 templates/

Create database

Set a default DATABASE_URL in .env. For example:

DATABASE_URL="mysql://root@127.0.0.1:3306/myDatabase"

Developers can set a custom DATABASE_URL by creating a .env.local file and setting a custom value.

Next, create the database

symfony console doctrine:database:create

Start server

symfony serve

View API docs

You can browse to /api to browse your API.

Install maker bundle

composer req maker --dev

Create your first resource

See this post.

Sources