You’ve Got To Go Forwards To Go Back

Another week goes by, and another newsletter where I can’t announce the launch of the revised version of CodeReviewVideos. It’s killing me.

I’ve pulled a PHP 6.

I’m now onto CodeReviewVideos version 3, and yet version 2 never got released! Oh my.

What’s most amusing to me is that v3 is so similar to v1 in terms of look-and-feel that I almost needn’t have bothered. Good times. Good times.

Anyway, I still have an absolute ton of stuff left to do, so today’s update is going to be short and sweet.

Video Update

This week saw three new videos added to the site:

#1 – Docker PHP Symfony Tutorial

In order to get a Symfony stack up and running with Docker there are a few pieces that already need to be in place.

These are your webserver (nginx, in our case), and likely a database (mysql, for us).

Our web stack

Also, being that Symfony uses PHP, we kinda need PHP available inside the Docker container 🙂

Now the good news is that we sorted out PHP last week. We created a ‘base’ image, based on PHP 7.1.

We can now use as the starting point for any PHP project we do. This could be Symfony, or WordPress, or Slim, or whatever.

In our case this will be a Symfony Docker image.

And what this means is that we will do a bunch of Symfony-specific tasks such as copying over the app , src , web , and bin  directories, and setting up the parameters.yml  file.

By the end of this video you will have all the pieces of the puzzle (the puzzle being: how to get a Symfony stack up and running in Docker) ready to go.

You could – if you were being particularly cruel on yourself – decide that you’re going to docker run all these images and get everything hooked up by hand.

Or, if you prefer life being that little bit easier then you could use Docker Compose to make this task massively simpler…

#2 – Docker Compose Tutorial

In a nutshell, Docker Compose allows you to define an environment in which your project / code will run.

As above, in our case we need nginx for our web server, we need MySQL as our database server, and we need our Symfony code to run our application.

Docker Compose allows us to define how all of this fits together.

It might not make much sense as words, so here’s some real config:

version: '3'

services:

    db:
        image: mysql:5.7.19
        hostname: db
        volumes:
          - "./volumes/mysql_dev:/var/lib/mysql"
        env_file:
          - ./.env

    nginx:
        image: docker.io/codereviewvideos/nginx.symfony.dev
        hostname: nginx
        volumes:
          - "./volumes/nginx/logs:/var/log/nginx/"
          - "./:/var/www/dev"
        ports:
          - 81:80
        depends_on:
          - php

    php:
        image: docker.io/codereviewvideos/symfony.dev
        hostname: php
        volumes:
          - "./volumes/php/var/cache:/var/www/dev/var/cache/:rw"
          - "./volumes/php/var/sessions:/var/www/dev/var/sessions/:rw"
          - "./volumes/php/var/logs:/var/www/dev/var/logs/:rw"
          - "./:/var/www/dev"
        env_file:
          - ./.env
        depends_on:
          - db

Even if you don’t understand how it all works, the likelihood is you can figure out what it will do if you were to run docker-compose up  against this config.

However, one of my goals with CodeReviewVideos is to ensure you do understand how. And so in this video we cover exactly that.

#3 – Docker Compose Tutorial For Elixir and Phoenix Framework

In this tutorial series we are covering how to get a working Phoenix Framework environment up and running with Docker.

In case you aren’t aware, Phoenix is a web framework written in Elixir, a rather interesting functional programming language.

The main reason for this tutorial series is to show you that the back end and front end code can be completely separate entities.

We could use Symfony as our back end. We could use Laravel. We could use Django, or Rails, or in this case, Phoenix.

Ultimately, in most of my projects lately, all my back end does is serve up a JSON API.

From the point of view of the front end (React, Angular, Vue, some mobile app, or whatever), it doesn’t matter – at all – how the back end works. It just needs to work.

One of the often repeated pieces of advice for programmers who want to improve their craft is to “learn a different language”.

We aren’t going to be learning Elixir here. If there is interest then I would be happy to share what I know.

However this series is intended to show you how to achieve a working JSON API, and quickly, in a different environment to that which you might be used to.

Hopefully you find it interesting regardless of whether you decide to investigate Elixir / Phoenix any further.

And that’s about it for me this week.

I’ve had a lot of requests lately for “how to deploy Symfony“, so this will be covered in next week’s videos.

Until next week, have a great weekend and happy coding.

Chris

Published by

Code Review

CodeReviewVideos is a video training site helping software developers learn Symfony faster and easier.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.