Modern OOP PHP with Docker

<p>OOP: Object-Oriented Programming. Emphasis on using classes and objects.</p> <h1>Setup a basic example with Docker</h1> <p>Let&rsquo;s set up an example using Docker, WSL2 and Ubuntu that will take this format:</p> <pre> php_oop1/ |-- docker-compose.yml |-- Dockerfile |-- src/ |-- index.php |-- MyClass.php</pre> <p>Open your distro (previously installed Ubuntu on WSL2), then:</p> <pre> $ ls ~ docker-projects</pre> <p>In your Docker projects folder create a working directory with some empty files we&rsquo;ll use for tutorial purposes:</p> <pre> mkdir php_oop1 cd php_oop1 mkdir src touch Dockerfile docker-compose.yml src/index.php src/MyClass.php</pre> <p>We will build the Docker image using the contents of the&nbsp;<code>src</code>&nbsp;directory and place it into the default web/document root, which is recognizable from standard Apache installations. In this context, Apache is bundled with PHP. We create the files before defining the Dockerfile because the Docker image we want to use is built based on this file. The build process is static; therefore, if we modify any content within the&nbsp;<code>src</code>&nbsp;directory, the Docker image must be rebuilt to reflect those changes.</p> <p><a href="https://medium.com/@jumjumjum/modern-oop-php-with-docker-b494969d5626"><strong>Learn More</strong></a></p>
Tags: Modern PHP