Skip to content

Replace stub/regex with symfony/yaml for compose.yaml manipulation#37

Merged
ryoluo merged 2 commits intomainfrom
devin/1771652608-yaml-library
Feb 21, 2026
Merged

Replace stub/regex with symfony/yaml for compose.yaml manipulation#37
ryoluo merged 2 commits intomainfrom
devin/1771652608-yaml-library

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Feb 21, 2026

Replace stub/regex with symfony/yaml for compose.yaml manipulation

Summary

Replaces the fragile stub file + regex/string replacement approach for modifying compose.yaml with proper YAML parsing and dumping via symfony/yaml.

Before: Raw text manipulation using preg_replace to inject stub file contents after services:/volumes: markers, and str_replace for path rewriting.

After: Yaml::parseFile() to parse compose file into a PHP array, array manipulation to add/modify services and volumes, Yaml::dump() to write back valid YAML.

Key changes:

  • Added symfony/yaml as an explicit dependency (^5.4|^6.0|^7.0)
  • InstallCommand: nginx service config defined as a PHP array instead of a stub template; duplicate detection uses isset($dockerCompose['services']['nginx']) instead of str_contains on raw text
  • PublishCommand: volume path replacement operates on the parsed array instead of raw string
  • Deleted stubs/nginx.stub and stubs/volume.stub
  • Tests updated to assert YAML structure (parsed arrays) instead of checking for literal stub text in the output
  • Exception type in tests updated from ErrorException to Symfony\Component\Yaml\Exception\ParseException to match the new Yaml::parseFile() behavior

Review & Testing Checklist for Human

  • Verify Yaml::dump() output is compatible with docker-compose: Yaml::dump($data, 10, 4) rewrites the entire compose file. Check that quoting/escaping of ${...} environment variables (e.g. ${HTTP_PORT:-8000}:80, ${APP_SERVICE:-laravel.test}) is preserved correctly and doesn't break docker-compose variable interpolation. CI tests verify parsed structure only, not runtime compatibility.
  • Test end-to-end in a real Laravel Sail project: Run sail-ssl:install followed by sail-ssl:publish and verify the resulting compose file works with docker compose up. This is the most important verification since Yaml::dump() may produce subtly different formatting from the original stubs.
  • Review the hardcoded nginx config array in InstallCommand: The nginx service definition previously lived in stubs/nginx.stub and is now a PHP array in InstallCommand.php. Confirm it matches the intended service configuration.

Notes


Open with Devin

Co-Authored-By: Ryo Kobayashi <cuba6vst@gmail.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Co-Authored-By: Ryo Kobayashi <cuba6vst@gmail.com>
Copy link
Contributor Author

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@ryoluo ryoluo merged commit f7557be into main Feb 21, 2026
5 checks passed
@ryoluo ryoluo deleted the devin/1771652608-yaml-library branch February 21, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant