Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fvsch/kirby4-default-model-loading
Reproduction for an issue (or feature request) with Kirby 4
https://github.com/fvsch/kirby4-default-model-loading
Last synced: 29 days ago
JSON representation
Reproduction for an issue (or feature request) with Kirby 4
- Host: GitHub
- URL: https://github.com/fvsch/kirby4-default-model-loading
- Owner: fvsch
- Created: 2023-11-18T11:40:29.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-08-19T16:09:29.000Z (3 months ago)
- Last Synced: 2024-08-19T19:02:54.577Z (3 months ago)
- Language: PHP
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kirby 4 issue with using the DefaultPage model class
## Context
Kirby CMS 4 introduces a new optional `DefaultPage` page model class in `site/models/default.php`:
https://getkirby.com/releases/4.0/default-page-model
This model is used when a page type doesn't have a matching model, e.g. a page of type `article` without a matching `ArticlePage` class in `site/models/article.php`.
An issue arises when one wants to create a specific page model that _extends_ the `DefaultPage` model:
```php
Uncaught Error: Class "DefaultPage" not found in site/models/aaa.php:3## Steps to reproduce
1. Download this repository
2. Install dependencies with composer: `composer install`
3. Run the PHP dev server with `composer run dev` (uses port `8000`, you can change it in `composer.json`)
4. Open the resulting site (`http://localhost:8000` by default).You should see the `Class "DefaultPage" not found` error.
You can enable a workaround that registers a class autoloading function with `spl_autoload_register`, by running the dev server with:
```sh
KIRBY_AUTOLOAD_MODELS=true composer run dev
```