Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev Container and making api-platform more friendly to new users #2472

Open
ili101 opened this issue Jul 5, 2023 · 1 comment
Open

Dev Container and making api-platform more friendly to new users #2472

ili101 opened this issue Jul 5, 2023 · 1 comment

Comments

@ili101
Copy link
Contributor

ili101 commented Jul 5, 2023

Description
I'm trying to use API platform for the first time. So far it took me 2 days just to set the basics up (mostly because the 3.0.10 Dockerfile issue, #2471, some Docker problems, trying to set up XDEBUG, understanding the basics and so).
I prefer using VSCode and Docker and not PhpStorm as I develop in multiple languages and I don't want a different IDE for every thing I do.
And with Devcontainer I don't need PHP or anything installed on my OS, it also can take care of all the configurations for you.

Example
I managed to get the basic working in here https://github.com/ili101/api-platform/tree/Devcontainer
To use this and get a working development environment basically all you need is:

  1. Make sure you have VSCode and Docker installed.
  2. git clone the code.
  3. open VSCode on the folder, it will popup a massage asking if you want to open the detected Dev Container, yes.
  4. you are set up with PHP Intelephense, PHP Debug and Symfony Extensions, to line debug just F5 and and a brakepoint as xdebug is set up.

Some considerations I encountered are:

  1. In the exiting api Dockerfile only the api folder is mapped (to /srv/app/), it's not comfortable to develop without the full repo in your IDE. to bypassed this by mapping the root of the repo to /workspace (so basically api is mapped twice, and I needed to point xdebug to the new mapped folder otherwise it will only work if you put the breakpoints on /srv/app/ and not /workspace).
    Another option instead of mapping twice is to map the root to /srv but as you currently "rename" "api" to "app" the stuff pointing to /srv/app/ will need to point to /srv/api/ instead.
  2. the Alpine Linux is a bit slim and less comfortable/compatible to develop on as a dev environment, maybe it will be better to create a separate api Dockerfile in the /devcontainer folder that is based on something like mcr.microsoft.com/devcontainers/php:1-8.2-bullseye.
    For example the devcontainer.json "features" option (auto install optional stuff in your container) do not work on Alpine.

For reference I found that Laravel also have a way to set devcontainer for you automaticly with curl -s "https://laravel.build/example-app?with=mysql,redis&devcontainer.

What do you think?

@dunglas
Copy link
Member

dunglas commented Jul 18, 2023

Very cool work!
I'm +1 to add support for devcontainer in the main repo. WDYT @api-platform/core-team?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants