Skip to content

fix: Update composer.json start script target folder during migrations#117

Open
lemmon wants to merge 1 commit intogetkirby:mainfrom
lemmon:fix/composer-start-script-target-folder
Open

fix: Update composer.json start script target folder during migrations#117
lemmon wants to merge 1 commit intogetkirby:mainfrom
lemmon:fix/composer-start-script-target-folder

Conversation

@lemmon
Copy link
Copy Markdown

@lemmon lemmon commented Jan 24, 2026

Description

This PR fixes an issue where the migrate:to:public-folder and migrate:to:root-folder commands didn't update the composer.json start script's target folder configuration for the PHP built-in development server.

Problem

When migrating between folder setups:

  • Public folder migration: The composer.json start script wasn't updated to include -t public flag, causing the development server to serve from the wrong directory
  • Root folder migration: The composer.json start script wasn't updated to remove the -t public flag, causing the development server to fail or serve from the wrong directory

Solution

Added updateComposerConfig() method to both migration classes that:

  • Detects PHP built-in server commands in composer.json scripts.start
  • Updates the target folder flag (-t public) appropriately based on the migration direction
  • Only modifies commands matching the standard localhost:8000 pattern

Changes

  • Added updateComposerConfig() method to PublicFolder class
  • Added updateComposerConfig() override to RootFolder class
  • Both methods are called during their respective migration processes
  • Updates are only made when composer.json exists and contains matching start scripts

Testing

  • Verified the code follows existing codebase patterns
  • Confirmed error handling is consistent with other commands
  • Tested logic handles edge cases appropriately for development tool usage

Related

Fixes the issue where composer start wouldn't work correctly after running migration commands.

- Add updateComposerConfig() method to PublicFolder migration
- Add updateComposerConfig() method to RootFolder migration
- Automatically update PHP built-in server target folder (-t public) flag
- Ensures development server works correctly after folder structure migration

Fixes issue where migrate:to:public-folder and migrate:to:root-folder
didn't update the composer start script's target folder configuration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant