Many missing or unclear steps in the "Getting Started With API Platform with Symfony" page
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 文档
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- docker, next.js, php, postgresql, symfony
- 领域
- devops, documentation
调研方向
从“Getting Started with API Platform with Symfony”页面开始,将每条命令与此处描述的生成的 compose.yaml 和 installer 输出进行比较。检查 pnpm、Doctrine、数据库重建、profiler 和 Next.js generator 的步骤,然后在全新项目中验证整个操作流程。完成的标准是:页面说明了前置条件并提供了一条可正常工作的文档化路径,或者对于超出其范围的失败,明确链接到相关 issue。
由索引模型根据 Issue 内容生成。
描述
I've tried to setup a completely new project with the api-platform installer by following the documentation for symfony Getting Started with Api Platform with Symfony but I hit a few snags.
Installing the Framework
Scaffolding the Project
Executing the following command failed because I didn't have pnpm installed.
api-platform bookshop-api --framework=symfony --with-docker --with-pwa --with-admin
There is no mention until this point that pnpm is required for the pwa. Since the documentation for the Next.js Generator mentions npm, pnpm and yarn as possible package managers I would expect that creating the project would work with just npm or yarn installed.
After installing pnpm and running the command again, the installation succeeded.
I then ran the following command to start the containers.
cd bookshop-api/api
docker compose up --wait
The documentation states that two services will be spun up - php and database - but only the php service was started. It is mentioned, that the installer requires the Doctrine ORM bridge via api-platform/doctrine-orm - which is installed automatically - but that doesn't install the actual dependencies to use Doctrine or interact with the database.
Looking at the compose.yaml I can only see the php container and no database. But hidden in the compose.yaml is this comment
services:
php:
restart: unless-stopped
environment:
SERVER_NAME: ${SERVER_NAME:-localhost}, php:80
....
# Run "composer require symfony/orm-pack" to install and configure Doctrine ORM
DATABASE_URL: postgresql://${POSTGRES_USER:-app}:${POSTGRES_PASSWORD:-!ChangeMe!}@database:5432/${POSTGRES_DB:-app}?serverVersion=${POSTGRES_VERSION:-15}&charset=${POSTGRES_CHARSET:-utf8}
so I've executed docker compose exec php composer require symfony/orm-pack to install the Doctrine ORM.
Installing this dependency modifies some files in the project. For example the Dockerfile to add the pdo_pgsql extension for php.
It adds the database service to the compose.yaml and adds a DATABASE_URL environment variable to the .env file.
These changes require the container to be rebuilt as it isn't just installing php dependencies but directly modifying the Dockerfile.
In my first attempt there was another issue after installing the orm-pack. Somehow the php container could not talk to the database container. I assume this was some networking problem and might be related to the DATABASE_URL inserted into the .env file.
It's Ready
I opened https://localhost and could access the swagger documentation. Trying out the GET /greetings route fails with a 404 error (which I have reported here: https://github.com/api-platform/api-platform/issues/3003)
Bringing your Own Model
After creating the two new classes with the #[ApiResource] attribute, the documentation mentions the Web Debug Toolbar. This toolbar is not automatically installed. You need to install it with docker compose exec php composer require symfony/profiler-pack
A Next.js Web App
I switched to the pwa directory and executed pnpm create @api-platform/client. It asked for some inputs but then just printed the help page of the client generator. No actual frontend was generated.
Looking at the documentation of the client generator I should run one of these two commands
docker compose exec pwa \
pnpm create @api-platform/client --resource book -g next
OR
pnpm create @api-platform/client https://demo.api-platform.com . --generator next --resource book
There is no pwa container configured through the Api Platform installer so I tried to run the second command (with https://localhost as url)
but that fails because of an invalid certificate ...
At this point I am pretty disappointed with the "onboarding" experience of api-platform and the installer.
- 主要语言
- 没有语言数据
- 星标
- 181
- 派生
- 1.1k
- 平均合并
- 1 天 10 小时
- 30 天内合并 PR
- 24
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
api-platform/docs 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
api-platform/docs#2284 ·
-
难度 4/5 3-5 天 新手友好度 45/100
api-platform/docs#2310 ·
-
难度 4/5 3-5 天 新手友好度 35/100
api-platform/docs#2280 · 2 条评论 ·
-
Needs Work
难度 4/5 3-5 天 新手友好度 35/100
api-platform/docs#2133 · 9 条评论 · 1 个 reaction ·
-
good first issue
难度 1/5 1 小时以内 新手友好度 58/100
api-platform/docs#1450 · 2 条评论 ·
查看 api-platform/docs 的全部 Issue
相似的 Issue
-
core dependencies
难度 1/5 1 小时以内 新手友好度 80/100
-
bug github_actions
难度 2/5 1-3 小时 新手友好度 75/100
registrystack/registry-stack#1393 ·
-
module: core
难度 2/5 1-3 小时 新手友好度 75/100
bigbluebutton/bigbluebutton#25849 ·
-
bug engine
难度 2/5 1-3 小时 新手友好度 65/100
rocky-data/rocky#2181 ·
-
难度 2/5 1-3 小时 新手友好度 70/100