An idea for Pinegrow 3 an PHP

I understand your problem and it is the way that Pinegrow works. It is not a code editor for PHP, it is a front end designer making all the pretty and content presentation stuff that the end user sees and interacts with. All the server side programming stuff is outside the purview of Pinegrow and should as I suggest be separate within your code as well.

It does take rethinking the design of your site and how your code works to accomplish. To generate the output without server side code being within the HTML.

In Templates I design I use keywords or special tags that get replaced with generated content. The templates are 100% Html with no code, php in them at all. When you look at the php code there is no htrml there either, just a bunch of rules for creating the output in the format required. I save the final output to static html pages and just update them as content is updated. Makes things run smoother and pages load quicker than having to process everything at each page request. To make the code so it is not dependant on a specific theme or template does take some thinking but is worth it.

That is one way I do it. Gives you an idea that it is not necessary to have everything in one file. I program using OOP so I have classes that do the necessary work and makes things easier to maintain.

If the problem you are having, with not being able to separate the html from your code is getting in your way then you will need to grab the final output generated and work with that within Pinegrow. Then break it a part and reinsert your php code where it needs to go once the design is the way you want it.