Giter Site home page Giter Site logo

Build Status

What is this thing?

Handy boilerplate to get up and running with the following:

  • PHP-FPM v7.4.1
  • Symfony v5.x
  • Nginx
  • Docker
  • jQuery
  • Monolog

Install/Setup

$ git clone [email protected]:mferly/mferly.git

You'll need to edit a few files before you get up and running. They're are:

  • ./docker/nginx/conf/app.conf
    • root /path/to/your/project;
    • server_name localhost; # assuming you need to
    • Setup up SSL if you desire.
  • ./docker/nginx/Dockerfile
    • Ensure paths are correct
    • Setup SSL if desired
  • ./.env
    • Change APP_NAME to whatever you want
      • It's used in:
        • docker-compose.yml
        • docker-compose-develop.yml
  • ./docker-compose.yml
    • Not much, if anything, that needs changing in here
  • ./docker-compose-develop.yml
    • Changes needed if you want SSL
  • ./Dockerfile
    • Add/remove PHP packages as needed
    • Also check that the following are correct for your env:
      • COPY . /var/www/app
      • RUN sh /var/www/app/bin/build.sh

Once all of that is sorted out move on down to the 'Run' section (but first check out 'Certs/SSL' if you want SSL).

Certs/SSL

NOTE: If you don't want to run over HTTPS then you can skip the following set of instructions. However, I'd strongly encourage you to run over HTTPS at all times, especially since it's such an easy setup. Either way, it's setup for both port 80 and 443.

To create a local self-signed cert I recommend looking into mkcert. Super simple setup. Eg..

$ git clone [email protected]:FiloSottile/mkcert.git

$ cd mkcert

$ mkcert -install

Then you can create a cert for an array of hosts or simply specify a single one..

$ mkcert example.local "*.example.local" localhost 127.0.0.1 ::1

// or simply

$ mkcert example.local

Don't forget to edit your /etc/hosts file if you're using a host other than localhost..

$ sudo vi /etc/hosts

>> /etc/hosts

// add a line similar to the following..

127.0.0.1       example.local

Now we..

  • Copy those new .pem files to ./docker/nginx/certs
  • Update the following to reflect your new certs (if applicable)
    • ./docker-compose-develop.yml
    • ./Dockerfile-nginx
    • ./docker/nginx/conf/self-signed.conf

Alternatively, when you're ready to go prime time, you can look into Let's Encrypt as a free solution to your SSL needs. Local, self-signed certs (as we have here) won't suffice in production, but they're easy to setup to get the ball rolling.

Run

Build our images

/**
 * Replace PROJECT_NAME with your project name
 *   eg. my_app
 * The following will build and tag your docker images
 *   per PROJECT_NAME
 */
$ sh ./docker-build.sh PROJECT_NAME

Dev

Develop is mounted to local app directory for ease of development via volumes.

.env

Update APP_ENV to dev, eg. APP_ENV=dev

Composer

// let's use the composer.lock file
$ composer update

Yarn

Install Yarn and then run it to install the packages in package.json.

/**
 * Make sure you have yarn installed
 * Yarn will use the provided yarn.lock file
 */
$ yarn
/**
 * This command will watch changes made to your
 * .css and .js files
 */
$ yarn run encore dev --watch

Docker compose

$ docker-compose -f docker-compose-develop.yml up

Prod

For production we don't mount local volumes (obviously).

.env

Update APP_ENV to prod, eg. APP_ENV=prod

$ docker-compose up -d

Swarm

$ docker stack deploy --compose-file docker-compose.yml app

Logging

We're using Monolog (more specifically the symfony/monolog-bundle).

More resources here:

To do

  • Docker alpine images
  • Tests

mferly's Projects

mferly icon mferly

Use this boilerplate to spin up a Docker app using PHP-FPM, Symfony5, and Nginx.

php-enum icon php-enum

PHP Enum implementation inspired from SplEnum

reactphp icon reactphp

Event-driven, non-blocking I/O with PHP.

session-parser icon session-parser

Use this to iterate through active session files within the defined PHP sessions folder found in php.ini to look for authenticated sessions.

yasumi icon yasumi

Yasumi is an easy PHP Library for calculating national holidays

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.