1

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?

0

The setting on whether a template has PHP parsing turned on lives in the exp_templates, under the allow_php column (either y or n) and the php_parse_location column (either i or 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

  1. Dump the exp_templates table pre-commit
  2. Add that dump file to your commit
  3. Repo gets pushed from dev to production here
  4. 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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.