Still a bit new with EE2, but I'm looking to be able to construct a way we can push changes up in environments, without having to sync up database-level stuff. Right now I have several templates that are being changed to include PHP in them. Part of what I want to get right is making sure PHP is enabled in our production environment when we go to push. Is there a way in code to set this flag on a given template? Or is the only solution in the database?
The setting on whether a template has PHP parsing turned on lives in the
exp_templates, under the
allow_php column (either
n) and the
php_parse_location column (either
o). This question really pertains to practices related to versioning, as I assume you would use a VCS tool for pushing code from development to production.
Programatically, you can always modify the database using the Database class, but that isn't what you're looking for. If you are using git, I would recommend using git hooks.
I would use a hook to
- Dump the
- Add that dump file to your commit
- Repo gets pushed from dev to production here
- Use a server-side hook to run an update to that table with the dump
It seems like a convoluted way to go about it, but that should essentially push your
exp_templates table along with your code, but not interrupt your channel data or other tables. This can also have the unfortunate effect of overwriting production changes to templates that were done during development time. Perhaps if you could expand on your teams planned development to production path (agile sprints or something?), and how stable the production deployments are going to be, we can help more.
Edit Whether a template gets pulled from file or template, there is still a read from the
exp_templates table in the EE engine to determine PHP parsing. If you want to just have a post-push trigger, you could write a PHP script that looks at both development and production tables, does a comparison of those columns, and then updates the production rows to match the development ones, using a git hook.