With Docker and docker-compose its already much better than in the past with virtual machines utilized by Virtualbox or any other memory bleeding app.To have an easy setup for all possible PHP versions with debugging enabled, I found a really good Docker image from Webdevops including PHP with development configuration and a NGINX webserver.
Docker Docker.For..Localhost For Mac OSX A PredefinedFor Mac OSX a predefined host variable called docker.for.mac.localhost exists, that automatically keeps the IP of your docker host: Ping the predefined host inside of the Docker container Now just run docker-compose up and you get your application served and you can follow the log output in the current terminal session: Nginx output of the running container Enable Xdebug with PHPStorm To enable a debugging session with PHPStorm and Docker you need to configure the IDE like this: Steps in the GIF to configure Xdebug in PHPStorm: Click Add configuration in the Toolbar Click and add PHP Remote Debug Select filter debug connection and add a host with a Path mapping to app Set the IDE key to PHPSTORM Debugging works How to run composer or other CLI scripts To install Frameworks like Symfony or add external dependencies to your application you need to run composer commands.
Docker Docker.For..Localhost How To List InstalledTo access the bash of your running PHP container just execute: docker-compose exec php bash Now you can run any php scripts in cli mode, like composer show to list installed packages: Output of an executed cli command How to run Symfony Its really easy to run Symfony with the showed setup. Just run the container and execute the following cli script to install the framework: composer create-project symfonywebsite-skeleton myprojectname Symfony gets installed and you can browse it locally by entering in your browser without any further configuration. Symfony works with no additional config Summary As you can see the webdevops Docker images simplify the programmers life to setup a PHP application development environment in almost no time. Written by Stefan Pltl Follow 25 25 25 Docker PHP Symfony Debugging Software Development More from Stefan Pltl Follow More From Medium Application Health Check with Golang and Multi-Stage Docker Build Stefan Pltl Deploying a Symfony 45 Application on AWS Fargate (part 1) Jrmy Levy in The Scaffold blog Efficient testing with fixtures on Symfony 4 Pablo Godinez in Manomano Tech Top 10 Python GUI Frameworks for Developers Claire D. Improving your tests with DoctrineFixturesBundle Gerardo Fernndez Setting up Symfony with Imagine library and cloud storage (Amazon S3) efficiently, on top of k8s Doried Abd-Allah in The Startup Auto-Increment is the Devil: using UUIDs in Symfony and Doctrine Titouan Galopin Create your first PHPMySQL application in docker Adnan Siddiqi in FAUN About Help Legal Get the Medium app. I dont want to put the backend into the dockercomposes.yml and connect them by link. Eg: if your host IP is 192.168.1.7 you can use 192.168.1.7:5000. Much easier to change local IP in a config file for local dev than start interfering with the container. Example frontend can reach backend using backend:5000 where backend is the name the backend container. Attach the backend container to this network using docker container attach app-network. Note that localhost from the perspective of the container is not the host machine. There several ways to connect to the host machine from with the container. ![]() Making statements based on opinion; back them up with references or personal experience. Not the answer youre looking for Browse other questions tagged docker docker-compose or ask your own question.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |