使用文件存储、数据库或两者的 PHP 模板编辑器? [英] PHP Template editor using file storage , database or both?

查看:57
本文介绍了使用文件存储、数据库或两者的 PHP 模板编辑器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很困惑我想为我的 php 模板引擎创建一个基于浏览器的模板编辑器.所以用户可以从控制器面板更新代码(类似于wordpress外观->编辑器)

i'm really confused i want to create a browser based template editor for my php template engine. so the use can update the code from the controller panel (something like the wordpress appearance->editor)

问题是我应该使用文件存储并使用 glob 并使用 file_put_content 更新文件并使用 file_get_contents 获取它.

the question is what should i use a file storage and get the template list by using glob and update the file using file_put_content and get it using file_get_contents.

或将模板名称和模板描述保存在数据库中并将模板存储在文件中

or save the template names and a description for the templates in the database and store the templates in a files

或将它们全部存储在数据库中

or store them all in a database

我真的很困惑,有人能给我一个好的答案吗(但考虑到性能,由于性能原因,我使用了默认的 php 模板引擎).

i'm really confused could someone give me a good answer please (but put performance in mind i used the default php template engine because of perfromance).

提前致谢

推荐答案

如果您使用平面文件,您将能够在生成的模板上轻松利用操作码缓存(如 APC).但是,您还必须实现一个信号量来处理同时写入文件的尝试.

If you go with flat files, you'll be able to easily leverage opcode caches like APC with on the generated templates. However, you'll also have to implement a semaphore to handle simultaneous attempts to write to the files.

与数据库方法相反,您可以免费获得互斥逻辑,但必须编写其他内容才能根据数据库内容在生产中创建平面文件,以便将它们 APC 缓存.

Conversely with the database approach, you get mutual exclusion logic for free, but would have to write something else to create flat files in production, based on the db content, to get them APC cached.

这篇关于使用文件存储、数据库或两者的 PHP 模板编辑器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆