{"id":15745236,"url":"https://github.com/mtfoley/docker-php-mysql","last_synced_at":"2025-06-16T23:32:26.457Z","repository":{"id":111982579,"uuid":"232010497","full_name":"mtfoley/docker-php-mysql","owner":"mtfoley","description":"Docker Setup for PHP \u0026 MySQL","archived":false,"fork":false,"pushed_at":"2020-01-07T02:15:24.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-31T05:44:50.699Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mtfoley.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-06T02:40:55.000Z","updated_at":"2020-01-07T02:15:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"cecdb3ef-e299-4059-b564-441502f9c70c","html_url":"https://github.com/mtfoley/docker-php-mysql","commit_stats":{"total_commits":6,"total_committers":2,"mean_commits":3.0,"dds":"0.33333333333333337","last_synced_commit":"3aa9b15ee1fea938481f3e3b6a720067aa716470"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mtfoley/docker-php-mysql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtfoley%2Fdocker-php-mysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtfoley%2Fdocker-php-mysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtfoley%2Fdocker-php-mysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtfoley%2Fdocker-php-mysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mtfoley","download_url":"https://codeload.github.com/mtfoley/docker-php-mysql/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtfoley%2Fdocker-php-mysql/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260260733,"owners_count":22982577,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-04T04:02:30.842Z","updated_at":"2025-06-16T23:32:26.416Z","avatar_url":"https://github.com/mtfoley.png","language":"PHP","readme":"# docker-php-mysql\nDocker Setup for PHP \u0026amp; MySQL (or LAMP stack, I guess). This is meant to be just enough code to get a PHP container and MySQL container up and running so they can be used for an app.\n\nUsage:\n\nThe commands I used the most were:\n```\t\n$ docker-compose build  \n$ docker-compose up -d\n$ docker-compose down\n$ docker ps\n$ docker network inspect [CONTAINER]\n$ docker exec -it [CONTAINER] bash\n\n``` \n\nWhat I Learned:\nI had a lot of trouble getting the PHP container to be able to access the MySQL container. There were multiple things I had to change to get it right:\n- The instruction of ```command: --default-authentication-plugin=mysql_native_password``` in docker-compose.yml. This was needed because in MySQL v8, there was a change in the default authentication plugin, and the mysql library in PHP wouldn't be compatible (and probably same for other stacks).\n- The use of a custom network \"app-net\" in docker-compose.yml. \n- The use of a hostname to connect to the MySQL. I left the \"hostname\" configuration option in the docker-compose.yml, but in the end, the PHP container uses the service name (\"db\") as the hostname to connect to the database.\n- I got so tired of making fine adjustments on the PHP container to help it connect to the MySQL, and it wasn't until toward the end that I figured out I could try things out using the PHP executable in interactive mode in order to make fine adjustments to function calls: ```docker exec -it [CONTAINER] php -a```\n\nTODO:\n- On my machine, it takes a few seconds before src/index.php successfully connects to the MySQL database. Would be good to look into how to force the db container to start first.\n- I should rewrite src/index.php to show it actually has access to the drafts table on MySQL\n- The line changing the /etc/hosts file doesn't seem to do anything for me. Perhaps this would only be practical if I were somehow using a web browser on the container itself?\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtfoley%2Fdocker-php-mysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmtfoley%2Fdocker-php-mysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtfoley%2Fdocker-php-mysql/lists"}