PHPackages                             trungdv/base-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. trungdv/base-laravel

ActiveLibrary[Database &amp; ORM](/categories/database)

trungdv/base-laravel
====================

Base Laravel Package - Quick Docker environment setup for Laravel development

v1.0.1(6mo ago)01MITPHPPHP ^8.1

Since Oct 22Pushed 6mo agoCompare

[ Source](https://github.com/trungdv-fabbi/base-laravel)[ Packagist](https://packagist.org/packages/trungdv/base-laravel)[ Docs](https://github.com/trungdv-fabbi/base-laravel)[ RSS](/packages/trungdv-base-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (3)Used By (0)

Base Laravel Package
====================

[](#base-laravel-package)

A comprehensive Laravel package for quickly initializing a base Laravel development environment with Docker setup, providing utilities for file management, template generation, and consistent API responses.

Features
--------

[](#features)

- 🐳 **Docker Environment**: Complete Docker setup with Nginx, MySQL, and Laravel
- ⚡ **Quick Setup**: One command to initialize your development environment
- 🔧 **Configurable**: Customizable PHP and MySQL versions
- 📁 **Auto-generated**: Automatically creates necessary Docker files and configurations
- 🚀 **Laravel Ready**: Pre-configured for Laravel development
- 🛠️ **Helper Utilities**: File and directory management tools
- 📝 **Template System**: Stub-based file generation
- 🎯 **Response Resource**: Consistent API response formatting
- 🔗 **Facade Support**: Easy-to-use facade interface
- 📊 **Service Container**: Full Laravel integration

Requirements
------------

[](#requirements)

- PHP &gt;= 8.1
- Laravel &gt;= 9.0
- Docker &amp; Docker Compose
- Composer

Installation
------------

[](#installation)

### 1. Install via Composer

[](#1-install-via-composer)

```
composer require trungdv/base-laravel
```

### 2. Publish Configuration

[](#2-publish-configuration)

```
php artisan vendor:publish --provider="TrungDV\BaseLaravel\Providers\InitBaseProvider" --tag="config"
```

### 3. Configure Environment

[](#3-configure-environment)

Update your `.env` file with database configuration:

```
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=root
DB_PASSWORD=your_password
DB_TIME_ZONE=UTC
```

Usage
-----

[](#usage)

### Initialize Base Environment

[](#initialize-base-environment)

Run the following command to create your Docker environment:

```
php artisan make:base
```

This command will create:

- `docker-compose.yml` - Docker Compose configuration
- `docker/` directory with:
    - `Dockerfile` - PHP-FPM container configuration
    - `http-nginx.conf` - Nginx configuration
    - `php.ini` - PHP configuration
    - `initdb/` - Database initialization scripts
    - `mysql/` - MySQL logs directory

### Start Development Environment

[](#start-development-environment)

After running `make:base`, build and run your Docker environment:

```
docker-compose up -d --build
```

Your Laravel application will be available at:

- **HTTP**:
- **HTTPS**:

### Stop Development Environment

[](#stop-development-environment)

```
docker-compose down
```

Configuration
-------------

[](#configuration)

The package configuration is located in `config/base.php`:

```
return [
    /*
    |--------------------------------------------------------------------------
    | Default init base directory
    |
    */
    'project_name' => 'base_laravel',
    'php_version' => '8.3',
    'mysql_version' => '8.0',

    'path' => 'app/Repositories',
    'service_path' => 'app/Services',

    /*
     * Default repository namespace
     */
    'namespace' => 'App\Repositories',
    'service_namespace' => 'App\Services',
    'naming' => 'singular', // plural | singular

    'response' => [
        'headers' => [
            'Content-Type' => 'application/json,charset=UTF-8',
            'Access-Control-Allow-Credentials' => 'TRUE',
            'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, DELETE, PUT, PATCH',
            'Access-Control-Allow-Headers' => 'x-requested-with',
            'Access-Control-Max-Age' => '864,000',
        ],
    ],
];
```

### Customizing Versions

[](#customizing-versions)

You can customize PHP and MySQL versions by updating the config:

```
// config/base.php
'php_version' => '8.2',    // Change PHP version
'mysql_version' => '8.0',  // Change MySQL version
'project_name' => 'my_project', // Change project name
```

Docker Services
---------------

[](#docker-services)

### Laravel Application

[](#laravel-application)

- **Container**: `{project_name}_laravel`
- **Image**: Custom PHP-FPM image (`trungdvfabbi/php-pecl:php{PHP_VERSION}`)
- **Port**: 9000 (internal)
- **Volumes**: Project files, PHP configuration

### Nginx Web Server

[](#nginx-web-server)

- **Container**: `http-nginx`
- **Image**: nginx:1.23-alpine
- **Ports**: 9005 (HTTP), 443 (HTTPS)
- **Configuration**: Custom nginx config for Laravel

### MySQL Database

[](#mysql-database)

- **Container**: `{project_name}_db`
- **Image**: mysql:8.0
- **Port**: 33061 (external)
- **Volumes**: Database data, logs, initialization scripts

Template System
---------------

[](#template-system)

The package uses a stub-based template system for generating files:

### Available Templates

[](#available-templates)

- `docker-compose.stub` - Docker Compose configuration
- `Dockerfile.stub` - PHP-FPM Dockerfile
- `http-nginx.conf.stub` - Nginx configuration
- `php.ini.stub` - PHP configuration

Troubleshooting
---------------

[](#troubleshooting)

### Common Issues

[](#common-issues)

1. **Port Already in Use**

    - Change ports in `docker-compose.yml` if 9005 or 33061 are already in use
2. **Permission Issues**

    - Ensure Docker has proper permissions to access your project directory
    - Check file ownership: `ls -la`
3. **Database Connection Issues**

    - Verify your `.env` database configuration matches the Docker setup
    - Check if MySQL container is running: `docker-compose ps`
4. **Container Won't Start**

    - Check Docker logs: `docker-compose logs [service_name]`
    - Verify Docker is running: `docker --version`
5. **Template Not Found**

    - Ensure template files exist in `src/Stubs/` directory
    - Check file permissions and naming convention

### Debugging

[](#debugging)

```
# View all container logs
docker-compose logs

# View specific service logs
docker-compose logs laravel
docker-compose logs mysql
docker-compose logs http-nginx

# Access container shell
docker-compose exec laravel bash
docker-compose exec mysql bash

# Check container status
docker-compose ps

# Restart specific service
docker-compose restart laravel
```

Contributing
------------

[](#contributing)

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

Support
-------

[](#support)

If you encounter any issues or have questions:

- 📧 Email:
- 🐛 Issues: [GitHub Issues](https://github.com/trungdv-fabbi/base-laravel/issues)
- 📖 Documentation: [Package Documentation](https://github.com/trungdv-fabbi/base-laravel)

Changelog
---------

[](#changelog)

### v1.0.0 - 2024-01-15

[](#v100---2024-01-15)

- ✅ Initial release
- ✅ Docker environment setup with Nginx, MySQL, and Laravel
- ✅ Configuration management system
- ✅ Response resource for consistent API responses
- ✅ Helper utilities for file and directory management
- ✅ Template system for file generation
- ✅ Facade support for easy usage
- ✅ Service Container integration
- ✅ Artisan command for environment initialization
- ✅ Comprehensive testing setup
- ✅ Complete documentation and examples

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance66

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

200d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9fe575a5d11329025c64f2e33645eef88aad6dc512cb61bbf04eab50fb5dc5ab?d=identicon)[trungdv-fabbi](/maintainers/trungdv-fabbi)

---

Top Contributors

[![trungdv-fabbi](https://avatars.githubusercontent.com/u/54126491?v=4)](https://github.com/trungdv-fabbi "trungdv-fabbi (3 commits)")

---

Tags

laravelmysqlenvironmentdevelopmentdockernginxbaseinit

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/trungdv-base-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/trungdv-base-laravel/health.svg)](https://phpackages.com/packages/trungdv-base-laravel)
```

###  Alternatives

[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[cybercog/laravel-clickhouse

ClickHouse migrations for Laravel

163166.8k](/packages/cybercog-laravel-clickhouse)[guanguans/laravel-dump-sql

laravel 中轻松容易的输出完整的 SQL 语句。 - Easy output of complete SQL statements for laravel framework.

3635.6k](/packages/guanguans-laravel-dump-sql)[yii2tech/illuminate

Yii2 to Laravel Migration Package

11315.1k](/packages/yii2tech-illuminate)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)[matthew-p/docker-server

Universal docker server, Nginx, PHP-FPM, MySql, Redis

112.8k](/packages/matthew-p-docker-server)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
