Skip to content

leaf serve is completely broken in MVC projects — delegates to leafs/schema instead of a serve handler #324

@lelandyang

Description

@lelandyang

Describe the bug

leaf serve in an MVC project is completely non-functional due to a broken
delegation chain:

  1. Global leaf CLI detects MVC app via isMVCApp()
  2. Delegates to php leaf serve locally
  3. Local vendor/bin/leaf proxies to leafs/schema bin (a database migration tool)
  4. leafs/schema has no serve command — fails silently, all requests return 404

To Reproduce

  1. Scaffold a fresh Leaf MVC project
  2. Run leaf serve from the project root
  3. Visit http://localhost:5500/

Expected behavior

App is served correctly, routes respond as defined.

Actual behavior

All requests return 404, including /. The server starts but nothing works.

Root cause

In ServeCommand.php:

if ($this->isMVCApp()) {
    return (int) sprout()->run("php leaf serve --port={$this->option('port')} --ansi", null);
}

vendor/bin/leaf resolves to leafs/schema/bin/leaf, not a serve handler.

Workaround

Add to composer.json:

"scripts": {
    "serve": "php -S localhost:5500 -t public public/index.php"
}

Then run composer run serve.

Environment

  • leafs/cli version: v4.6.0
  • leafs/sprout version: 0.9.2
  • leafs/schema version: 0.1.1
  • OS: Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions