![]() I’m using APP_NAME variable to avoid some extra copy-pasting in the configurations, but that’s completely up to you. You might already have default port 3306 occupied on your local machine. use ports 81 for project A, 81 for project B and so on… The same applies to the DB port. Stick with some convention and be consistent.Į.G. In the same manner, I’ll map a port for PhpMyAdmin. You must make sure that the port is not occupied already and map available ports from your local machine to the container’s port 80. As a part of this guide, I will not configure the local machine’s hosts file to make site access more user-friendly, but will access it over localhost. env file, we’ll have project-level Docker environment variables. For starters, the codebase folder is empty. Since this will be a Symfony app, we will have a public folder with an index.php file within it and that’s what we’ll rely on throughout the setup. Make sure, if you’re going to rename them, to rename them accordingly in the configurations.Ĭodebase folder will hold all our project code. Maybe it will be easier to follow if I provide the final folder structure first, so here it is. ![]() If you’re using Windows, make sure you have the WSL2 feature enabled. Prerequisites are installed Docker and Docker Compose (which, depending on your platform, might be a part of the Docker installation). I intend to have multiple projects locally with this exact stack, so I had to come up with something simple enough and reusable to get me started quickly, but something I can build on top of and extend when necessary. On top of my Symfony project, I’ll add PhpMyAdmin to save me some trouble when manually dealing with DB stuff. I’ll also use Apache for the server and MariaDB for the database. Symfony 5.2 includes support for PHP 8 attributes to define routes and required dependencies, and that’s one more argument in favor of it. I think it’s worth using the latest versions when starting fresh, so that’s the stack I’m dealing with. Let’s get startedĪll my new projects will be using PHP 8 because of some great features I’d like to exploit which were not there prior to version 8. ![]() What I can do is encourage you into having a look at this great “Docker for local web development” series where you can learn much more. I don’t intend to get into the details of each line of code and explain all used commands. Docker can be really slow, but listing the pros and cons of Docker is not the topic here. ![]() I’ve decided to use Docker for my local development because different projects I’m working on require different versions of PHP, NodeJS and even different versions of Composer… and switching/upgrading/downgrading those versions whenever I switched my focus on another project became cumbersome. Well, either my searching skills are getting rusty or my request was too specific while at the same time being pretty basic, or something would crash and break during the build process after following available online tutorials or downloading existing projects… but I couldn’t find a single solution which I could reuse for my exact needs with just a couple of changes in the configuration, so I had to come up with my own. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |