VOOZH about

URL: https://deepwiki.com/guanguans/ai-commit/6.1-development-environment-setup

⇱ Development Environment Setup | guanguans/ai-commit | DeepWiki


Loading...
Menu

Development Environment Setup

Purpose and Scope

This document provides instructions for setting up a local development environment for the ai-commit project. It covers system requirements, installation methods, development dependencies, and environment configuration necessary for contributing to or extending the codebase.

For information about running tests after setup, see Testing Framework. For information about code quality tools and linting, see Code Quality Tools. For building and packaging the application, see Build and Release Process.


System Requirements

PHP Version and Extensions

The ai-commit project requires specific PHP versions and extensions to function correctly.

RequirementVersion/StatusPurpose
PHP>= 8.2Core language requirement
ext-curlRequiredHTTP client for AI API requests
ext-mbstringRequiredMulti-byte string handling

Sources: composer.json58-61

Runtime Environment Compatibility

The codebase is configured to support PHP 8.2 through 8.4, with testing performed across this range.


Sources: composer.json58-61 rector.php102


Installation Methods

Method 1: Download Pre-built PHAR (Recommended for Usage)


This method is suitable for end-users but not for development, as the PHAR is a compiled artifact.

Sources: README.md39-44

Method 2: Install via Composer (Recommended for Development)

For development work, install the project using Composer to access the full source code and development tools.


Development Installation Workflow:


Sources: README.md46-51 composer.json186-190


Dependency Architecture

Production Dependencies

The application relies on Laravel Zero as its foundation, with additional libraries for AI integration and text processing.


Key Dependencies:

PackageVersionPurpose
laravel-zero/framework^12.0CLI application framework
laravel/framework^12.36Core Laravel components
guzzlehttp/guzzle^7.10HTTP client for API requests
laminas/laminas-text^2.12Text manipulation utilities
laravel-zero/phar-updater^1.4Self-update functionality

Sources: composer.json58-68

Development Dependencies

The project includes extensive development tooling for code quality, testing, and analysis.


Critical Development Tools:

ToolVersionPurpose
pestphp/pest^3.8 || ^4.0Modern testing framework
phpstan/phpstan^2.1Static analysis
rector/rector^2.2Automated refactoring
friendsofphp/php-cs-fixer^3.88Code style fixing
larastan/larastan^3.7Laravel-specific PHPStan rules

Sources: composer.json69-124


Directory Structure and Key Files

Project Layout


Essential Configuration Files:

FilePurposeReferenced By
composer.jsonDependency management and scriptsComposer, CI/CD
bootstrap/app.phpApplication bootstrap and service registrationLaravel Zero
phpunit.xml.distPHPUnit test configurationPest, CI tests
rector.phpCode refactoring rulesRector commands
composer-dependency-analyser.phpDependency analysis configurationComposer scripts

Sources: composer.json133-148 bootstrap/app.php1-117 phpunit.xml.dist1-43


Post-Installation Setup

Automated Post-Install Tasks

Composer automatically runs several setup tasks after installation.


Post-Install Scripts:

The following scripts execute automatically after composer install:

  1. @cghooks add --ignore-lock - Installs Git hooks for commit quality checks
  2. @cghooks update - Updates hook configurations
  3. @composer-bin-all-update - Updates binary plugin dependencies

Post-Update Scripts:

After composer update, additional tasks run:

  1. @artisan vendor:publish --tag=laravel-assets --force - Publishes Laravel assets
  2. @artisan lang:update - Updates language files
  3. @cghooks update - Re-applies Git hooks
  4. @composer-bin-all-update - Updates tool dependencies
  5. @composer-diff - Shows dependency changes

Sources: composer.json186-197

Git Hooks Configuration

The project uses brainmaestro/composer-git-hooks to enforce code quality before commits.

Hook Behavior:

  • pre-commit: Runs composer checks before allowing commits
  • post-merge: Runs composer checks after merging branches

These hooks ensure code quality by running linting, testing, and static analysis automatically.

Sources: composer.json176-183


Environment Configuration

Application Bootstrap

The application bootstrap process is defined in bootstrap/app.php and handles critical initialization.

Bootstrap Sequence:


Key Bootstrap Actions:

  1. Singleton Registration - GeneratorManager registered as singleton
  2. Configuration Loading - ConfigManager::load() called during boot
  3. Service Provider Registration - Conditional registration of development tools
  4. Event Listener Setup - Xdebug handling and dynamic configuration

Sources: bootstrap/app.php36-116

Configuration Manager Initialization

The ConfigManager loads configuration from multiple sources during bootstrap.

Configuration Sources (in order of precedence):

  1. PHP defaults (config/ai-commit.php)
  2. Global JSON (~/.ai-commit/.ai-commit.json)
  3. Local JSON (./.ai-commit.json)
  4. CLI flags

Sources: bootstrap/app.php40-42


Verification Steps

Basic Installation Verification

After installation, verify the environment is correctly configured.


Run Health Checks

The project includes comprehensive check scripts.


Sources: composer.json222-242

Dependency Verification

Verify all dependencies are correctly installed and compatible.


Sources: composer.json248-249 composer.json264


Development Scripts Reference

Essential Composer Scripts

The project provides numerous Composer scripts for development tasks.

Testing Scripts:

ScriptCommandPurpose
test / pestcomposer testRun full test suite with coverage
test-bailcomposer pest-bailStop on first failure
test-coveragecomposer pest-coverageGenerate HTML coverage report

Code Quality Scripts:

ScriptCommandPurpose
style-lintcomposer style-lintCheck code style without fixing
style-fixcomposer style-fixFix code style issues
phpstancomposer phpstanRun static analysis
rector-dry-runcomposer rector-dry-runPreview refactoring changes

Utility Scripts:

ScriptCommandPurpose
artisancomposer artisanRun Artisan commands
checkscomposer checksRun all quality checks
lintcomposer lintPHP syntax checking

Sources: composer.json185-439


Tool Configuration Files

Code Quality Tool Setup

PHPStan Configuration:

PHPStan is configured via phpstan.neon (not shown in provided files, but referenced by scripts).


Sources: composer.json342-343

Rector Configuration:

Rector is extensively configured in rector.php with PHP 8.2 as the target version.

Key Rector Settings:

  • Target PHP Version: PHP 8.2
  • Paths Analyzed: app/, bootstrap/, resources/, tests/
  • Sets Applied: Dead code removal, code quality, coding style, type declarations
  • Laravel Rules: Laravel 11.0 ruleset applied

Sources: rector.php71-297

Dependency Analyzer Configuration:

The dependency analyzer is configured in composer-dependency-analyser.php.

Analyzed Paths:

  • app/
  • bootstrap/
  • config/
  • resources/
  • tests/

Ignored Dependencies:

  • laminas/laminas-text - Unused but required
  • laravel-lang/common - Unused but required
  • laravel-zero/phar-updater - Unused but required

Sources: composer-dependency-analyser.php17-71


Troubleshooting Common Setup Issues

PHP Version Mismatch

Problem: PHP version is below 8.2

Solution:


Missing PHP Extensions

Problem: ext-curl or ext-mbstring not found

Solution:


Composer Memory Limit

Problem: Composer runs out of memory during installation

Solution:


Sources: composer.json270

Git Hooks Conflicts

Problem: Git hooks prevent commits after installation

Solution:


Sources: composer.json214-221

Permission Issues with PHAR

Problem: Cannot execute downloaded ai-commit file

Solution:



Next Steps

After completing the development environment setup:

  1. Run Tests - Verify the installation by running the test suite. See Testing Framework
  2. Configure Code Quality Tools - Set up your IDE with linters and formatters. See Code Quality Tools
  3. Understand Build Process - Learn how to build and package the application. See Build and Release Process
  4. Review CI/CD - Understand automated workflows. See CI/CD Workflows

Sources: README.md241-267 composer.json1-479

Refresh this wiki

On this page