Installation Guide: Laravel + InfyOm + Docker

# Step-by-Step Guide: Laravel + InfyOm + Docker

## 1. Install Laravel (Correctly)

First, create a new Laravel project:

composer create-project –prefer-dist laravel/laravel my-laravel-app

Then, move into the project directory:

cd my-laravel-app

At this point, your folder structure should look like this:

“`
my-laravel-app/
│── app/
│── bootstrap/
│── config/
│── database/
│── public/
│── resources/
│── routes/
│── storage/
│── vendor/
│── .env
│── artisan
│── composer.json
│── …
“`

✅ Now Laravel is ready!

## 2. Set Up Docker for Laravel

Now, inside your Laravel project (my-laravel-app/), create a Docker setup.

📌 Create docker-compose.yml

Create a docker-compose.yml file:
“`
version: ‘3.8’

services:
app:
build:
context: .
dockerfile: Dockerfile
container_name: laravel_app
restart: always
working_dir: /var/www
volumes:
– .:/var/www
depends_on:
– mysql
– redis
networks:
– laravel

nginx:
image: nginx:latest
container_name: laravel_nginx
restart: always
ports:
– “8080:80”
volumes:
– .:/var/www
– ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
– app
networks:
– laravel

mysql:
image: mariadb:latest
container_name: laravel_mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: laravel
MYSQL_USER: laravel
MYSQL_PASSWORD: laravel
ports:
– “3306:3306”
volumes:
– db_data:/var/lib/mysql
networks:
– laravel

redis:
image: redis:latest
container_name: laravel_redis
restart: always
networks:
– laravel

networks:
laravel:
driver: bridge

volumes:
db_data:

“`

### Create Dockerfile

Create a Dockerfile inside your Laravel project:
“`
FROM php:8.2-fpm

# Install system dependencies
RUN apt-get update && apt-get install -y \
zip unzip curl git libpng-dev libjpeg-dev libfreetype6-dev libonig-dev libxml2-dev libzip-dev \
&& docker-php-ext-configure gd –with-freetype –with-jpeg \
&& docker-php-ext-install gd mbstring pdo pdo_mysql zip xml

# Install Composer
COPY –from=composer:latest /usr/bin/composer /usr/bin/composer

# Set working directory
WORKDIR /var/www

# Copy existing application files
COPY . /var/www

# Ensure required directories exist
RUN mkdir -p /var/www/storage /var/www/bootstrap/cache

# Set permissions
RUN chown -R www-data:www-data /var/www \
&& chmod -R 775 /var/www/storage /var/www/bootstrap/cache || true

CMD [“php-fpm”]
“`

### Create Nginx Config

Inside your Laravel project, create docker/nginx/default.conf:
“`
server {
listen 80;
index index.php index.html;
server_name localhost;
root /var/www/public;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
include fastcgi_params;
fastcgi_pass app:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

location ~ /\.ht {
deny all;
}
}
“`

### Start Docker

Now, run:

docker-compose up -d –build

✅ Laravel is now running inside Docker!

## 3. Install InfyOm Generator

Now that Laravel is running, install InfyOm Labs Laravel Generator inside the Docker container.

Step 1: Install Required Packages

Run the following inside the app container:
“`
docker-compose exec app composer require infyomlabs/laravel-generator –dev
docker-compose exec app composer require laravel/ui
docker-compose exec app composer require infyomlabs/adminlte-templates –dev
“`

Step 2: Publish Config Files

Run:
“`
docker-compose exec app php artisan vendor:publish –provider=”InfyOm\Generator\InfyOmGeneratorServiceProvider”
docker-compose exec app php artisan vendor:publish –provider=”InfyOm\AdminLTETemplates\AdminLTETemplatesServiceProvider”
“`

Step 3: Install UI for Laravel

Run:
“`
docker-compose exec app php artisan ui bootstrap –auth
“`

Step 4: Generate CRUD Scaffold

For example, if you want to generate a Post CRUD, run:
“`
docker-compose exec app php artisan infyom:scaffold Post –fromTable –tableName=posts
“`
✅ This will generate:
– Model: Post.php
– Controller: PostController.php
– Views: resources/views/posts/
– Routes: routes/web.php
– Migration: database/migrations/…_create_posts_table.php

Now, run migrations:
“`
docker-compose exec app php artisan migrate
“`

## 5. Run Laravel Server

Run Laravel inside the container:
“`
docker-compose exec app php artisan serve –host=0.0.0.0 –port=8000
“`
Visit http://localhost:8000 to see your Laravel app.

### Summary

– Step 1: Install Laravel
– Step 2: Setup Docker (docker-compose.yml, Dockerfile, nginx.conf)
– Step 3: Install InfyOm (composer require infyomlabs/laravel-generator)
– Step 4: Generate CRUD (php artisan infyom:scaffold ModelName)
– Step 5: Run Laravel (php artisan serve)

Now, your Laravel + InfyOm boilerplate is ready! 🚀🔥

Tags:

Discover more from Juzhax Technology

Subscribe now to keep reading and get access to the full archive.

Continue reading