Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Contributing to WP Env
# Contributing

Thank you for considering contributing to WP Env! This document outlines the process for contributing to this project.
Thank you for considering contributing! This document outlines the process for contributing to this project.

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a [code of conduct](CODE_OF_CONDUCT.md), please follow it in all your interactions with the project.

## Development Workflow

Expand Down Expand Up @@ -54,13 +58,13 @@ vendor/bin/phpunit --coverage-html coverage/
### Code Quality
```bash
# Run all quality checks
composer qa
composer quality

# Individual tools
composer lint # PHP CS Fixer + PHPStan + Rector
composer static-analysis # PHPStan only
composer lint # Linters
composer analysis # Static analysis
composer security # Security check
composer code-quality # PHPMND + PHP Parser
composer quality # Code quality
```

## Coding Standards
Expand Down Expand Up @@ -105,7 +109,7 @@ test(hooks): add comprehensive hook testing

declare(strict_types=1);

namespace WpSpaghetti\WpEnv;
namespace WpSpaghetti\ExampleNamespace;

/**
* Class documentation.
Expand Down Expand Up @@ -135,16 +139,14 @@ class ExampleClass
```php
public function testMethodReturnsExpectedValue(): void
{
$result = Environment::get('TEST_VAR', 'default');
$result = ExampleClass::get('TEST_VAR', 'default');
self::assertSame('expected', $result);
}
```

### Mock Data
Use the provided mock functions for testing:
- `set_mock_constant()`
- `set_mock_env_var()`
- `set_mock_file()`
- `set_mock_*()`

## Documentation

Expand Down Expand Up @@ -175,8 +177,8 @@ When adding new features:

3. **Test Your Changes**
```bash
composer qa # Run all quality checks
composer test # Run all tests
composer quality # Run all quality checks
composer test # Run all tests
```

4. **Commit Changes**
Expand Down
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# These are supported funding model platforms

github: [wp-spaghetti]
github: [frugan-dev]
buy_me_a_coffee: frugan
2 changes: 1 addition & 1 deletion .github/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Supported Versions

We actively support the following versions of WP Env with security updates:
We actively support the following versions with security updates:

| Version | Supported |
| ------- | ------------------ |
Expand Down
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ updates:
time: "09:00"
open-pull-requests-limit: 10
assignees:
- "wp-spaghetti"
- "frugan-dev"
commit-message:
prefix: "deps"
include: "scope"
Expand All @@ -25,7 +25,7 @@ updates:
time: "09:00"
open-pull-requests-limit: 5
assignees:
- "wp-spaghetti"
- "frugan-dev"
commit-message:
prefix: "ci"
include: "scope"
Expand Down
3 changes: 3 additions & 0 deletions docs/LINKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
## Related

- https://github.com/kucrut/vite-for-wp
- https://github.com/evo-mark/wp-vite
- https://github.com/evo-mark/wordpress-vite-plugin
- https://github.com/kaisekidev/kaiseki-wp-vite
- https://pragmate.dev/wordpress/vite/integration/
- https://github.com/pragmatedev/
16 changes: 8 additions & 8 deletions src/Vite.php
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,15 @@ private static function getConfig(): array
return self::$config;
}

// Determine Docker-aware defaults
$isDockerEnv = Environment::isDocker();
// For Docker internal communication, use container name if we're inside Docker
$defaultServerHost = $isDockerEnv ? 'node' : self::DEFAULT_SERVER_HOST;

self::$config = [
// Server configuration (main Vite dev server)
'server' => [
'host' => Environment::get('VITE_SERVER_HOST', self::DEFAULT_SERVER_HOST),
'host' => Environment::get('VITE_SERVER_HOST', $defaultServerHost),
'port' => Environment::getInt('VITE_SERVER_PORT', self::DEFAULT_SERVER_PORT),
'https' => Environment::getBool('VITE_SERVER_HTTPS'),
],
Expand All @@ -612,7 +617,7 @@ private static function getConfig(): array

// Environment detection
'env' => [
'is_docker' => Environment::isDocker(),
'is_docker' => $isDockerEnv,
'debug_mode' => Environment::isDebug(),
'dev_server_enabled' => Environment::getBool('VITE_DEV_SERVER_ENABLED', true),
'dev_check_timeout' => Environment::getInt('VITE_DEV_CHECK_TIMEOUT', 1),
Expand Down Expand Up @@ -774,14 +779,9 @@ private static function getServerUrl(): string
{
$config = self::getConfig();

// For Docker internal communication, use container name if we're inside Docker
$host = $config['env']['is_docker']
? Environment::get('VITE_SERVER_HOST', 'node')
: $config['server']['host'];

$protocol = $config['server']['https'] ? 'https' : 'http';

return \sprintf('%s://%s:%d', $protocol, $host, $config['server']['port']);
return \sprintf('%s://%s:%d', $protocol, $config['server']['host'], $config['server']['port']);
}

/**
Expand Down