Skip to main content

Laravel Sail

 Laravel Sail అంటే ఏమిటి?

Laravel Sail అనేది Docker Compose wrapper.

సాధారణ Dockerలో:

docker run ...
docker compose up ...
docker compose down ...

ఇలా commands ఇవ్వాలి.

కానీ Sailలో:

./vendor/bin/sail up
./vendor/bin/sail down
./vendor/bin/sail artisan migrate

అంటే Docker commands ని simplify చేస్తుంది.


📋 Prerequisites

Windowsలో:

✅ Docker Desktop Installed

Check:

docker --version
docker compose version

Expected:

Docker version 28.x
Docker Compose version v2.x

🚀 Existing Laravel Project Run చేయడం

నీ project folder కి వెళ్ళు.

ఉదాహరణ:

cd C:\xampp\htdocs\myproject

Step 1: .env Configure

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=sail
DB_PASSWORD=password

⚠️ ముఖ్యమైన విషయం:

Dockerలో MySQL container name mysql

అందుకే:

DB_HOST=127.0.0.1

కాదు

DB_HOST=mysql

Step 2: Check docker-compose.yml

Laravel Sail install అయితే ఇలా ఉంటుంది:

services:
laravel.test:
build:
context: './vendor/laravel/sail/runtimes/8.3'
ports:
- '${APP_PORT:-80}:80'

mysql:
image: 'mysql/mysql-server:8.0'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'

ఇక్కడ రెండు containers ఉన్నాయి:

  1. laravel.test
  2. mysql

Step 3: Start Containers

Linux/Mac:

./vendor/bin/sail up -d

Windows PowerShell:

vendor\bin\sail up -d

లేదా:

php artisan sail:install

తర్వాత:

vendor\bin\sail up -d

Step 4: Check Running Containers

docker ps

Example:

CONTAINER ID   NAMES

abc123 myproject-laravel.test-1
xyz456 myproject-mysql-1

ఇప్పుడు రెండు containers run అవుతున్నాయి.


Step 5: Browser Open

http://localhost

లేదా

http://localhost:80

Laravel page కనిపిస్తుంది.


🗄️ MySQL Access

Container లోకి వెళ్లి:

vendor\bin\sail mysql

లేదా

docker exec -it myproject-mysql-1 mysql -u sail -p

Password:

password

🔄 Run Migrations

vendor\bin\sail artisan migrate

🌱 Run Seeders

vendor\bin\sail artisan db:seed

📦 Install Composer Packages

vendor\bin\sail composer install

⚡ Run NPM

vendor\bin\sail npm install
vendor\bin\sail npm run dev

🛑 Stop Containers

vendor\bin\sail down

🔥 Rebuild Containers

Dockerfile మారితే:

vendor\bin\sail build --no-cache

తర్వాత:

vendor\bin\sail up -d

🧠 Sail Architecture

Docker Engine


Docker Compose


┌─────────────────┐
│ laravel.test │
│ PHP 8.3 │
│ Composer │
│ Artisan │
└─────────────────┘


┌─────────────────┐
│ mysql │
│ MySQL 8 │
└─────────────────┘

Laravel Container ↔ MySQL Container

Network ద్వారా communicate అవుతాయి.

అందుకే:

DB_HOST=mysql

పని చేస్తుంది.


Docker Beginnerగా నువ్వు తెలుసుకోవాల్సిన Sail Commands

vendor\bin\sail up -d

➡️ Start project

vendor\bin\sail down

➡️ Stop project

vendor\bin\sail artisan migrate

➡️ Run migrations

vendor\bin\sail tinker

➡️ Open tinker

vendor\bin\sail shell

➡️ Open container shell

docker ps

➡️ See containers

docker logs <container>

➡️ See logs


Docker నేర్చుకోవడానికి Laravel Sail చాలా మంచి practical example. Sail వాడుతూ నువ్వు క్రమంగా:

  • Images
  • Containers
  • Networks
  • Volumes
  • Docker Compose
  • Environment Variables

అన్నీ real-world projectలో నేర్చుకుంటావు.

నీ project లో docker-compose.yml లేదా compose.yaml file ఉంటే paste చేయి. నేను line-by-line తెలుగులో explain చేస్తాను.


Comments

Popular posts from this blog

Database and Migrations

Database and Migrations You can config Database in the .env file. By default, Laravel has MySQL configuration. For example, I configured my details DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=Laravel_tutorials DB_USERNAME=root DB_PASSWORD= So how it connects the database, In your root folder config/database.php file will read the .env file configuration. Migrations: Migrations are most likely a version control for your database. Advantages You can easily allow your team to modify database schema and share to everyone in the application No headache to add a new column in the database manually. This migration will help all teammates into one path. Now check with artisan command php artisan migrate php artisan migrate This command will create basic users,password_resets and migrations tables. Here migrations table will track of all migrates You can undo previous migration using rollback command php artisan ...

Data Types in Python

Data Types  In C# or Java, You need to declare a variable specify them integer, string, and decimal. But in Python no need to specify. We can declare variables like Example: C# or Java int age = 28; string Name = "Siddhu"; Example: Python age = 28 Name = "Siddhu" So, you don't need to declare variable types in python. This is an advantage in Python, But still have few Disadvantages too. Example: In my Python function def add_numbers(x,y): print(x+y) add_numbers(20,50) //Output: 70 add_numbers(20,"Something") //Error:"Traceback (most recent call last): File "C:/Users/siddhartha.e/PycharmProjects/siddhu-py/my1stpycode.py", line 8, in add_numbers(50,"Something") File "C:/Users/siddhartha.e/PycharmProjects/siddhu-py/my1stpycode.py", line 4, in add_numbers print(a + b) TypeError: unsupported operand type(s) for +: 'int' and 'str'" ...

How to see Competitor ads on their Facebook pages

In any type of business, the organization always concentrate on their competitor's activities when it comes to competition. The first thing wants to what competitors doing, how they are getting leads or traffic. The same pattern is going when you are running Facebook Ads. If you want to know your competitor facebook strategy you will not see them on the newsfeed. Fortunately, you can see them in the following way and replicate their success on your Facebook Ads. Here am giving step by step. Follow each step  Step 1: Open your competitor facebook page and see the right side content of the page and click on see more button of the page transparency section as per below image Step 2: After opening the page you can see the page history and  Ads from this page. Click on Go to Ad library.  Step 3: Select the country that you want to see the Ads and see the Ads monthly.