Skip to content

YannickFe/crudle

Repository files navigation

crudle

Create CRUD applications powered by API Platform with ease. It exposes a description in the OpenAPI format and integrates a by api-platfrom customized version of Swagger UI.

API Platform

The official project documentation is available on the API Platform website.

Install

Read the official "Getting Started" guide.

Build

docker compose build --no-cache

Run

docker compose up

Debug

docker compose logs -f

Running Multiple Instances

To run multiple instances of this project on the same host, you need to configure different ports for each instance to avoid port conflicts. The application uses the following environment variables to configure ports:

  • HTTP_PORT: The HTTP port (default: 80)
  • HTTPS_PORT: The HTTPS port (default: 443)
  • HTTP3_PORT: The HTTP/3 port (default: 443)

Example of running a second instance on different ports:

# First instance (default ports)
docker compose up -d

# Second instance (custom ports)
HTTP_PORT=50000 HTTPS_PORT=50001 HTTP3_PORT=50002 DATABASE_PORT=50003 docker compose up -d

You can also create a .env file for each instance with different port configurations.

Create new Entities

Using symfony maker bundle, you can create new entities.

# execute in /api directory
bin/console make:entity --api-resource

To generate new Entities using structured data (currently yaml or json), you can use the implemented app:entity-from-json maker command:

# provide path to a JSON or YAML file
php bin/console app:entity-from-json --file=../path/to/datefile

# or provide JSON data directly
php bin/console app:entity-from-json --data='{...}'

Since the automatic initialization of the database isn't implemented yet due to time crunch you need to:

cd crudle_instances/{id}/api # the commands below need to be executed in the symfony directory of the crudle instance 
symfony console doctrine:migrations:diff
symfony console doctrine:migrations:migrate

Here are two examples of structured data files you can use:

Example JSON file

{
    "name": "Book",
    "apiResource": true,
    "fields": [
        {
            "name": "title",
            "type": "string",
            "nullable": false
        },
        {
            "name": "publishedAt",
            "type": "datetime_immutable",
            "nullable": true
        },
        {
            "name": "isbn",
            "type": "string",
            "nullable": true
        },
        {
            "name": "pages",
            "type": "integer",
            "nullable": true
        }
    ]
}
name: Article
apiResource: true
fields:
    - name: title
      type: string
      nullable: false
    - name: author
      type: string
      nullable: false
    - name: publishedAt
      type: datetime_immutable
      nullable: true
    - name: content
      type: text
      nullable: true
    - name: views
      type: integer
      nullable: false

Credits

Yannick Fenz'l, Kévin Dunglas, and contributors.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors