Guide

Everything you need to know about setting up and using Lara Anchor.

On this page

1. Installation

1

Download & Extract

The install script downloads and extracts the latest template.

curl -s https://lara-anchor.netlify.app/install.sh | bash
2

Create Environment File

Update the database credentials in .env

cp .env.example .env
3

Start Containers

Starts PHP 8.5, MySQL 8.3, and optional Node 22 containers.

docker compose up -d
4

Install Dependencies

docker compose exec app composer install
5

Generate Application Key

docker compose exec app php artisan key:generate
6

Run Database Migrations

docker compose exec app php artisan migrate

Done! Your Laravel application is now running on http://localhost:8000

2. Configuration

Environment Variables (.env)

Key environment variables for Docker configuration:

APP_MEM_LIMIT=256m # Memory limit for PHP container
DB_MEM_LIMIT=512m # Memory limit for MySQL
DB_DATABASE=laravel # Database name
DB_USERNAME=laravel # Database user
DB_PASSWORD=secret # Database password
MYSQL_ROOT_PASSWORD=root # MySQL root password

Note: Always use strong passwords in production. Update MYSQL_PASSWORD and MYSQL_ROOT_PASSWORD.

3. Common Commands

Start Containers

docker compose up -d

Stop Containers

docker compose down

View Logs

docker compose logs -f app

Run Artisan

docker compose exec app php artisan <cmd>

Run Composer

docker compose exec app composer <cmd>

Access Database

docker compose exec mysql mysql -u laravel -p

Rebuild Containers

docker compose up -d --build

Run pnpm (Node)

docker compose --profile dev up -d
docker compose exec node pnpm install

4. Development Workflow

File Synchronization

Your Laravel project files are mounted as volumes. Changes are instantly reflected in the container without rebuilds.

Debug Mode

Enable debug mode in your .env file:

APP_DEBUG=true

Database Access

Connect to MySQL using a GUI client or command line:

  • Host: mysql
  • Port: 3306
  • User: laravel (or root)
  • Password: secret (check .env)
  • Database: laravel

5. Troubleshooting

Port Already in Use

Problem: Port 8000 is already in use.

Change the port in docker-compose.yml or kill the process:

lsof -i :8000
kill -9 <PID>

Database Connection Error

Problem: Can't connect to MySQL.

Ensure MySQL container is running:

docker compose ps

Permission Denied Errors

Problem: Cannot write to storage/ or bootstrap/ directories.

Fix permissions inside the container:

docker compose exec app chmod -R 777 storage bootstrap/cache

6. FAQ

Why no Nginx?

Laravel's built-in development server is sufficient for development and removes unnecessary complexity. For production, add Nginx separately.

Why no Redis?

Removed to keep the setup lightweight. If you need caching or queues, add it to docker-compose.yml. Most Laravel apps don't require it in development.

Can I use this in production?

This is designed for development. For production, consider adding Nginx, a reverse proxy, proper logging, and security configurations.

How do I add Redis?

Add a Redis service to docker-compose.yml and configure CACHE_DRIVER and QUEUE_CONNECTION in .env.

Can I modify memory limits?

Yes. Update APP_MEM_LIMIT and DB_MEM_LIMIT in .env, or edit mem_limit values in docker-compose.yml directly.

Need more help?

Check the troubleshooting section above or browse the official documentation.

Back to Home