brifiction / laravel-boilerplate

A Laravel 7 boilerplate, with Docker.

Home Page:https://entwurfhaus.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

laravel-boilerplate

GitHub GitHub release (latest by date) GitHub Workflow Status Docker Cloud Build Status Docker Pulls

Summary

This is a Laravel boilerplate project. Usage of the provided CI/CD products / services, are purely optional.

The Laravel boilerplate project focus:

To develop your Laravel application, with Docker, in a local environment.

Please review the files mentioned below, before performing any continued development:

  1. The composer.json file, please review sections such as require and require-dev.
  2. The package.json file. Delete package-lock.json file, if you're using yarn.
  3. Example helper functions, under app/Helpers. Delete them if not used or required, then update config/app.php under aliases.
  4. The tests/* files (more will be defined for CI/CD purposes).

Lastly, this boilerplate will be maintained, by updating to the latest Laravel version (upon official Laravel latest release, after reviewing the upgrade notes and change logs).

For more information, go to Laravel Release Notes.

Continuous Integration and Continuous Development (CI/CD)

GitHub

GitHub Actions

There are pre-defined example workflows. They are meant to be later customized, or define new workflows to tailor your development workflow needs:

Example workflows
  1. Testing each Laravel deployment on each supported OS.
  2. Running your Laravel PHPUnit tests.
  3. Install and test your PHP modules beforehand.
  4. Create your own Docker container action.

And so much more.

Docker

Below are the services defined in the docker-compose.yml file:

  1. Microsoft SQL Server (optional)
  2. MySQL (optional)
  3. NGINX
  4. PHP-FPM
  5. PhpMyAdmin (optional)
  6. Redis (optional)

The services mentioned above are mostly optional, as you are welcome to make any changes to the Dockerfile and docker-compose.yml files to suit your local development needs.

All Docker configurations for each service, are defined in the .docker folder structure.

How to use

  1. Modify your configurations for each service, that suits your needs. They are each located in the .docker folder.
  2. Modify your Dockerfile and docker-compose.yml files, to suit your containerization needs.
  3. Run composer install.
  4. Define your environment variables in the .env file, including your database connection driver.
  5. Run the docker-compose commands below in order.
    # Pulls an image associated with a service defined in a docker-compose.yml or docker-stack.yml file, but does not start containers based on those images.
    docker-compose pull
    # Services are built once and then tagged, by default as 'project_service'.
    docker-compose build
    # Builds, (re)creates, starts, and attaches to containers for a service, also as 'Detached mode'.
    docker-compose up -d
  6. That's it! Enjoy coding with Laravel!

Troubleshooting

  1. There were some changes made with the Docker containers, why aren't they showing changes made?

    Try below in order, following commands should help make each build helpful for development workflow.

    # Stops containers and removes containers, networks, volumes, and images created by up.
    docker-compose down
    # Services are built once and then tagged, by default as 'project_service'.
    docker-compose build
    # If no changes to Dockerfiles.
    docker-compose build --no-cache
    # Builds, (re)creates, starts, and attaches to containers for a service, also as 'Detached mode'.
    docker-compose up -d
  2. Some Linux packages are not installing, or have an error returned for some of them. How do we resolve these issues?

    Based on the error(s) received, it varies from incorrect packages installed with mismatched OS type, to deprecated package names used. However, it is still all about modifying the apt-get commands in the Dockerfile at project root.

Microsoft SQL Server PDO Drivers

The online resources for the sqlsrv pdo drivers constantly changes, however would like to leave a note here that you'll need them to be added as a php extension, in order to make a successful mssql database connection.

It is like any other database driver, just that these are obtained and configured differently, as opposed to postgres, sqlite and others.

Docker Compose commands

  1. docker-compose down (https://docs.docker.com/compose/reference/down/)
  2. docker-compose build (https://docs.docker.com/compose/reference/build/)
  3. docker-compose up (https://docs.docker.com/compose/reference/up/)

References

  1. Laravel (https://laravel.com/)
  2. PHP (https://www.php.net/downloads)
  3. Composer (https://getcomposer.org/)
  4. Docker Compose (https://docs.docker.com/compose/)
  5. GitHub Actions (https://docs.github.com/en/actions)

About

A Laravel 7 boilerplate, with Docker.

https://entwurfhaus.com

License:MIT License


Languages

Language:PHP 92.5%Language:Blade 3.4%Language:Dockerfile 3.2%Language:Shell 0.9%