Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Docker Apache Mysql Php Mongo Laravel Package

lombax85/docker-apache-mysql-php-mongo

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup for Laravel Development

  1. Install via Composer (if using the package as a dependency):

    composer require lombax85/docker-apache-mysql-php-mongo
    

    Note: This package is outdated (last release 2016) and primarily designed for Docker orchestration, not a traditional Composer package. For Laravel, you’d typically use this via Docker Compose or CLI integration.

  2. Alternative: Use Docker Compose Directly Clone the repo or manually define a docker-compose.yml mirroring its structure:

    version: '3'
    services:
      apache:
        image: httpd:2.4
        ports:
          - "80:80"
        volumes:
          - ./src:/usr/local/apache2/htdocs
      php:
        image: php:7.4-fpm
        volumes:
          - ./src:/var/www/html
      mysql:
        image: mysql:5.7
        environment:
          MYSQL_ROOT_PASSWORD: root
          MYSQL_DATABASE: laravel
        volumes:
          - mysql_data:/var/lib/mysql
      mongo:
        image: mongo:4.4
      workspace:
        image: appropriate/curl
        volumes:
          - ./src:/var/www/html
    volumes:
      mysql_data:
    
  3. First Use Case: Local Laravel Dev Environment

    • Map your Laravel project to the Apache container’s document root.
    • Use the workspace container to run Artisan commands:
      docker-compose exec workspace php artisan migrate
      
    • Access Laravel at http://localhost (Apache) with MySQL/MongoDB services linked.

Implementation Patterns

Workflow Integration with Laravel

  1. Database Migrations & Seeding

    • Use the workspace container to run Laravel’s CLI tools:
      docker-compose exec workspace php artisan migrate --env=local
      
    • For MongoDB (if using jenssegers/laravel-mongodb), ensure the MONGO_HOST env var points to the mongo service.
  2. Environment-Specific Config

    • Override Laravel’s .env for Docker:
      DB_CONNECTION=mysql
      DB_HOST=mysql
      DB_PORT=3306
      DB_DATABASE=laravel
      DB_USERNAME=root
      DB_PASSWORD=root
      
      MONGO_CONNECTION=mongodb
      MONGO_HOST=mongo
      MONGO_PORT=27017
      
    • Mount your .env file into the workspace container for consistency.
  3. Shared Storage for Sessions/Cache

    • The package’s "data directory" container can store Laravel’s storage/framework (sessions/cache) or bootstrap/cache. Mount a named volume:
      services:
        workspace:
          volumes:
            - laravel_storage:/var/www/html/storage
      volumes:
        laravel_storage:
      
  4. Debugging & Real-Time Reloading

    • Use docker-compose up with volumes mounted for live code reloading.
    • For Xdebug, extend the PHP container with:
      php:
        image: php:7.4-fpm
        volumes:
          - ./src:/var/www/html
        environment:
          XDEBUG_CONFIG: remote_host=host.docker.internal
        extra_hosts:
          - "host.docker.internal:host-gateway"
      
  5. Testing with Laravel’s HTTP Tests

    • Use the workspace container to run tests:
      docker-compose exec workspace php artisan test
      
    • Ensure APP_URL=http://apache in .env to match the container hostname.

Gotchas and Tips

Pitfalls

  1. Outdated Images

    • The package uses deprecated Docker images (e.g., php:5.6-fpm). Override in docker-compose.yml:
      php:
        image: php:8.1-fpm
      
  2. Networking Quirks

    • Containers default to an isolated network. Use docker-compose exec workspace ping mysql to verify connectivity.
    • For Laravel Valet/Forge, ensure host.docker.internal resolves to your host machine’s IP.
  3. Persistent Data

    • MySQL/MongoDB data is ephemeral unless volumes are defined. Always mount volumes for databases:
      mysql:
        volumes:
          - mysql_data:/var/lib/mysql
      
  4. PHP Extensions

    • The base PHP image lacks Laravel dependencies (e.g., pdo_mysql, bcmath). Extend the image:
      FROM php:8.1-fpm
      RUN docker-php-ext-install pdo_mysql bcmath
      
  5. CouchDB Deprecation

    • CouchDB is outdated and unsupported. Remove it from docker-compose.yml unless explicitly needed.

Debugging Tips

  1. Logs

    • Stream logs for a service:
      docker-compose logs -f apache
      
    • For PHP errors, check the Apache container’s logs:
      docker-compose exec apache tail -f /usr/local/apache2/logs/error_log
      
  2. Shell Access

    • Enter any container for debugging:
      docker-compose exec workspace bash
      
  3. Environment Variables

    • Verify env vars are passed correctly:
      docker-compose exec workspace env
      

Extension Points

  1. Custom PHP Configuration

    • Override php.ini by mounting a custom file:
      php:
        volumes:
          - ./php.ini:/usr/local/etc/php/conf.d/custom.ini
      
  2. Laravel Forge/Envoyer

    • Adapt the docker-compose.yml for production by:
      • Using non-root users.
      • Disabling Xdebug.
      • Mounting /var/www instead of the project root.
  3. CI/CD Integration

    • Use the same docker-compose.yml in GitHub Actions/GitLab CI:
      services:
        mysql:
          image: mysql:5.7
        # ... other services
      jobs:
        test:
          services:
            - mysql
          script:
            - docker-compose exec workspace php artisan test
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky