Skip to content

fix(view)!: properly handle scoped view-components#1435

Merged
brendt merged 18 commits intomainfrom
file-based-view-components
Jul 27, 2025
Merged

fix(view)!: properly handle scoped view-components#1435
brendt merged 18 commits intomainfrom
file-based-view-components

Conversation

@brendt
Copy link
Member

@brendt brendt commented Jul 27, 2025

TODO:

  • Refactor dynamic view component to be file-based
  • Remove ViewComponent interface and refactor AnonymousViewComponent
  • Update meta:view-component command
  • Make updates to the docs: Update view component docs and specs #1436
  • Always pass view data into view components

The breaking change is about view components not having access to outer scopes anymore (except for variables from the view itself):

<!-- x-base.view.php -->

{{ $title }}
<!-- Let's say `$title` was defined in the current view -->

<?php $title = 'Hello'; ?>

<!-- this won't work anymore: -->
<x-base />

<!-- you would need to explicitly pass in `$title`: -->
<x-base :title="$title" />

The other breaking change is the use statements within view files must now always go on top.

Originally, this PR was only meant to address #1425 , but in order to make it work, I'd have to refactor view-component scopes. That's why they are both combined. The scope change is the only thing people will notice, so I decided to name this PR accordingly.

Closes #1425

@brendt brendt changed the title feat(view)!: convert feat(view)!: convert class-based view components to file-based view components Jul 27, 2025
@brendt brendt marked this pull request as draft July 27, 2025 07:34
@brendt brendt changed the title feat(view)!: convert class-based view components to file-based view components fix(view)!: properly handle scoped view-components Jul 27, 2025
@brendt brendt marked this pull request as ready for review July 27, 2025 08:46
@brendt brendt merged commit c6237db into main Jul 27, 2025
97 of 99 checks passed
@brendt brendt deleted the file-based-view-components branch July 27, 2025 08:48
@brendt brendt mentioned this pull request Aug 18, 2025
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.

Drop support for class-based view components

1 participant