# .php file not rendered in Editor

**URL:** <https://forums.realmacsoftware.com/t/php-file-not-rendered-in-editor/46039>\
**Category:** Elements API\
**Created:** [January 22, 2025, 5:08pm UTC](https://forums.realmacsoftware.com/t/php-file-not-rendered-in-editor/46039 "2025-01-22T17:08:38Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![logrunner](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@logrunner](https://forums.realmacsoftware.com/u/logrunner)\
**Post date:** [January 22, 2025, 5:08pm UTC](https://forums.realmacsoftware.com/t/php-file-not-rendered-in-editor/46039/1 "2025-01-22T17:08:38Z")

</div>

A recent requested change was made to Custom Component Devpacks which allowed you to have .php files in the templates folder whereas previously you could only have .html files. This change meant it was easier to edit PHP code files in an editor such as Nova as the syntax would be highlighted correctly.

However, a downside is that the Elements editor no longer renders these files now that the filetype has been changed to .php.

Can the editor be changed to treat .php files as .html files so that at least the HTML content renders?

---

<div class="post-metadata">

**Author:** ![Bartje](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/bartje/32/1210_2.png) [@Bartje](https://forums.realmacsoftware.com/u/Bartje)\
**Post date:** [January 22, 2025, 6:05pm UTC](https://forums.realmacsoftware.com/t/php-file-not-rendered-in-editor/46039/2 "2025-01-22T18:05:11Z")

</div>

I frequently encounter the same issue where custom components don’t render in the editor, forcing me to switch to preview mode. This does diminish the WYSIWYG principle of Elements. Are there guidelines to maximize rendering in Edit mode?

---

<div class="post-metadata">

**Author:** ![dan](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/dan/32/28516_2.png) [@dan](https://forums.realmacsoftware.com/u/dan)\
**Post date:** [January 25, 2025, 11:23am UTC](https://forums.realmacsoftware.com/t/php-file-not-rendered-in-editor/46039/3 "2025-01-25T11:23:01Z")

</div>

No, we’ve never rendered PHP in the editor.

Javascript and PHP only get run/rendered in the Browser Preview. This is a safety/security measure so the editor doesn’t get broken or messed with.

---

<div class="post-metadata">

**Author:** ![dan](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/dan/32/28516_2.png) [@dan](https://forums.realmacsoftware.com/u/dan)\
**Post date:** [January 25, 2025, 11:25am UTC](https://forums.realmacsoftware.com/t/php-file-not-rendered-in-editor/46039/4 "2025-01-25T11:25:09Z")

</div>

> [@Bartje](#):
>
> I frequently encounter the same issue where custom components don’t render in the editor, forcing me to switch to preview mode.

This is probably because you’re using Javascript in a Custom Component and that doesn’t get rendered in the editor.

---

<div class="post-metadata">

**Author:** ![logrunner](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@logrunner](https://forums.realmacsoftware.com/u/logrunner)\
**Post date:** [January 25, 2025, 11:39am UTC](https://forums.realmacsoftware.com/t/php-file-not-rendered-in-editor/46039/5 "2025-01-25T11:39:24Z")

</div>

@dan I understand that you don’t render PHP; what I am asking for is that you treat a .php file as if it where a .html file.

If I have PHP code in file that has a filetype of .html, the file renders OK, Elements ignores the PHP. This was working fine until I changed the filetype to .php in the the Custom Component template, to make the external editing easier in a Custom Component.

At the moment I have to flip the filetype back and forth, which while doable isn’t productive. 😉

---

<div class="post-metadata">

**Author:** ![dan](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/dan/32/28516_2.png) [@dan](https://forums.realmacsoftware.com/u/dan)\
**Post date:** [January 25, 2025, 12:35pm UTC](https://forums.realmacsoftware.com/t/php-file-not-rendered-in-editor/46039/6 "2025-01-25T12:35:02Z")

</div>

Oh! In that case it sounds like a bug, php files should be getting processed just like html files.

Can you send us the dev pack (or a sample) showing the bug? so we can look into it and get it fixed.

---

<div class="post-metadata">

**Author:** ![logrunner](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@logrunner](https://forums.realmacsoftware.com/u/logrunner)\
**Post date:** [January 25, 2025, 2:59pm UTC](https://forums.realmacsoftware.com/t/php-file-not-rendered-in-editor/46039/7 "2025-01-25T14:59:27Z")

</div>

@dan I have emailed you some test files. 🙂

---

<div class="post-metadata">

**Author:** ![Bartje](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/bartje/32/1210_2.png) [@Bartje](https://forums.realmacsoftware.com/u/Bartje)\
**Post date:** [January 26, 2025, 10:54am UTC](https://forums.realmacsoftware.com/t/php-file-not-rendered-in-editor/46039/8 "2025-01-26T10:54:38Z")

</div>

@dan: the @if(edit) is a good solution. Definitely to display the styling of a component in the editor. The preview mode can then be easily used for the data.

---

<div class="post-metadata">

**Author:** ![dan](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/dan/32/28516_2.png) [@dan](https://forums.realmacsoftware.com/u/dan)\
**Post date:** [January 26, 2025, 12:14pm UTC](https://forums.realmacsoftware.com/t/php-file-not-rendered-in-editor/46039/9 "2025-01-26T12:14:36Z")

</div>

@logrunner Thanks for the file, I have tested it here and the PHP file is getting processed by Elements as you can see by the colour values changing when I preview it in Safari — Is this not what you get?

Edit: we’re just looking into this further… to see if we can improve things.

---

<div class="post-metadata">

**Author:** ![logrunner](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@logrunner](https://forums.realmacsoftware.com/u/logrunner)\
**Post date:** [January 27, 2025, 10:09am UTC](https://forums.realmacsoftware.com/t/php-file-not-rendered-in-editor/46039/10 "2025-01-27T10:09:51Z")

</div>

@dan, just to clarify what I meant. Yes it is working for me in safari, that isn’t the issue.

It isn’t working in the Editor. The only difference between the two Components (PHP Test and HTML Test) is the filetype in the Components Template folder. Both components contain PHP code. If I change the PHP Test Component to have a filetype of .html in the Template folder it renders in the Editor OK, regardless of the fact that the now .html file contains PHP code.

I am requesting that if the editor sees a .php file, it treats it as .html and renders it in the Editor. 🙂

---

<div class="post-metadata">

**Author:** ![dan](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/dan/32/28516_2.png) [@dan](https://forums.realmacsoftware.com/u/dan)\
**Post date:** [January 27, 2025, 1:32pm UTC](https://forums.realmacsoftware.com/t/php-file-not-rendered-in-editor/46039/11 "2025-01-27T13:32:35Z")

</div>

> [@logrunner](#):
>
> I am requesting that if the editor sees a .php file, it treats it as .html and renders it in the Editor. 🙂

Yup, understood 👍 I have added this high-up on the bug list to take a look at!

---

<div class="post-metadata">

**Author:** ![dan](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/dan/32/28516_2.png) [@dan](https://forums.realmacsoftware.com/u/dan)\
**Post date:** [January 30, 2025, 6:01pm UTC](https://forums.realmacsoftware.com/t/php-file-not-rendered-in-editor/46039/12 "2025-01-30T18:01:50Z")

</div>

@logrunner give beta 34 a whirl and let us know if the html rendering in PHP components is now working for you 🙏

> [@Elements Beta 34 (Build 23213)](https://forums.realmacsoftware.com/t/elements-beta-34-build-23213/46122):
>
> Hello again, Following up on [Beta 33 from Tuesday](https://forums.realmacsoftware.com/t/elements-beta-33-build-23199/46094), Beta 34 brings a mix of bug fixes and developer-focused improvements! rocket This update introduces a new plain link option in the link panel, paving the way for PHP support in upcoming components. Plus, PHP files in Dev Components now render HTML directly in the Editor! What’s New in Elements Beta 34 (Build 23213)? Added a plain link option in the link panel to support PHP in upcoming components PHP Files in Dev Components will now render…

---

<div class="post-metadata">

**Author:** ![logrunner](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@logrunner](https://forums.realmacsoftware.com/u/logrunner)\
**Post date:** [January 30, 2025, 7:06pm UTC](https://forums.realmacsoftware.com/t/php-file-not-rendered-in-editor/46039/13 "2025-01-30T19:06:02Z")

</div>

Hi @dan, Yes, it does. Thanks for sorting that out. 😀
