Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
June 22, 2021 06:31 pm GMT

Running Laravel on Docker is really easy with Kool

In just 3 simple steps, you can use Kool CLI's kool create command to start a new Laravel application running in a local Docker environment. Kool is an open source dev tool that makes using Docker for local development a lot easier.

Before you start, if you haven't done so already, you need to install Docker and Kool CLI.

1. Create a new Laravel application

$ kool create laravel my-project

This command may take a minute or two to complete while Composer downloads Laravel's vendor dependencies. After installing Laravel, kool create automatically runs the kool preset laravel command, which helps you set up your project's development environment using an interactive wizard.

PHP

? What app service do you want to use  [Use arrows to move, type to filter]> PHP 8.0  PHP 7.4

Database

? What database service do you want to use  [Use arrows to move, type to filter]> MySQL 8.0  MySQL 5.7  MariaDB 10.5  PostgreSQL 13.0  none

Cache

? What cache service do you want to use  [Use arrows to move, type to filter]> Redis 6.0  Memcached 1.6  none

Package Manager

? What javascript package manager do you want to use  [Use arrows to move, type to filter]  npm> yarn

After selecting your preferences, the latest version of Laravel will be installed and ready for you in your my-project folder, along with your new kool environment.

kool preset laravel - output

Move into your new Laravel project:

$ cd my-project

The kool preset command auto-generated the following configuration files and added them to your project, which you can modify and extend.

+docker-compose.yml+kool.yml

2. Update .env.example

Next, we need to make a few tweaks to the default .env.example file that ships with Laravel in order to match the services in your docker-compose.yml file. For example, we need to change the hosts from localhost to the appropriate service container name, which are accessible from within Docker.

Database Services

MySQL 5.7 and 8.0 / MariaDB 10.5

-DB_HOST=127.0.0.1+DB_HOST=database

PostgreSQL 13.0

-DB_CONNECTION=mysql+DB_CONNECTION=pgsql-DB_HOST=127.0.0.1+DB_HOST=database-DB_PORT=3306+DB_PORT=5432

Cache Services

Redis

-REDIS_HOST=127.0.0.1+REDIS_HOST=cache

Memcached

-MEMCACHED_HOST=127.0.0.1+MEMCACHED_HOST=cache

3. Run kool run setup

Now, spin up your local environment for the first time using the setup script in your kool.yml file:

$ kool run setup

Note: if you're running this command for the first time, Docker may need to download all the container images that are being used, which can take a few minutes, depending on your internet connection.

That's it!

After kool run setup has finished, you can access your new Laravel app at http://localhost.

$ kool run setupCreating network "my-project_kool_local" with the default driverCreating volume "my-project_database" with default driverCreating volume "my-project_cache" with default driverCreating my-project_cache_1    ... doneCreating my-project_app_1      ... doneCreating my-project_database_1 ... done

kool laravel welcome screen

Dive Deeper

GitHub logo kool-dev / kool

From local development to the cloud: development workflow made easy.

kool - cloud native dev tool

Go Report CardcodecovDocker HubGolang CI LintMaintainabilityJoin Slack Kool community

About kool

kool is a CLI tool that helps bringing down to earth the complexities of modern software development environments - making them lightweight, fast and reproduceable. It takes off the complexity and learning curve of Docker and Docker Compose for local environments, as well as offers a highly simplified interface for leveraging Kubernetes cloud deployment for staging and production deployments.

Get your local development environment up and running easy and quickly, put time and effort on making a great application, and then leverage the Kool cloud for deploying and sharing your work with the world! This tool is suitable for single developers or large teams, powering them with a simple start and still provides all flexibility the DevOps team needs to tailor up everything.

To learn more check out our website kool.dev.

Installation

Requirements: Kool is powered by Docker so you need to have it already installed on


Original Link: https://dev.to/kooldev/running-laravel-on-docker-is-really-easy-with-kool-400h

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To