我如何组织我的PHP项目? [英] How do I structure my PHP project?

查看:124
本文介绍了我如何组织我的PHP项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我即将在另一个大型PHP项目着手。这一次,我打算在项目文件夹整齐!所以,我有关于保持我的项目的清洁和干燥几个问题:

I am about to embark upon yet another large PHP project. This time, I intend to have the project folder be tidy! So I have a few questions concerning keeping my project clean and DRY:

  • 我如何区分PHP源文件和PHP文件应该由浏览器访问的?换句话说,我怎么说清楚它的PHP文件给出了输出和这给函数或类的定义?

  • How do I differentiate between PHP source files and PHP files that should be accessed by the browser? In other words, how do I make it clear which PHP files gives output and which gives function or class definitions?

我就准备分开我的PHP功能于静态类,按主题分开,例如数据库::创建()或:写()。什么是对这个想法?

I am planning on separating my PHP functions into static classes, separated by subject, for instance database::create() or editor::write(). What are your thoughts on this?

我打算创建一个PHP文件core.php文件将包括在项目的每一个PHP文件的顶部。该文件将处理认证,包括基地的功能。思考?

I am planning on creating a PHP file "core.php" that will be included at the top of EVERY SINGLE PHP file in the project. This file will handle authentication and include base functions. Thoughts?

该项目将很大程度上基于Ajax的。这引出了一个问题:如果我的PHP函数是实际的PHP函数,或者他们应该是个别的PHP文件需要GET或POST输入?我的计划是这样做的两个。我创建了一个文件夹的PHP源文件,一个用于PHP的Ajax的文件(或东西),并有填充文件名由他们执行的功能,后者的文件夹。然后,PHP文件将只包含一个函数调用,并写入输出阿贾克斯。思考?

The project will be heavily Ajax based. This begs the question: Should my PHP functions be actual PHP functions, or should they be individual PHP files that takes GET or POST input? My plan is doing both. I create a folder for PHP source files and one for PHP "ajax" files (or something), and have the latter folder populated with files names by the functions they will perform. The PHP file will then simply contain a call to a function and write output for Ajax. Thoughts?

在我其他任何评论或提示开始这个项目将是巨大的!

Any other comments or tips before I start this project would be great!

我可能没有阿贾克斯是多么很大程度上基于此Web应用程序将被强调。 codeigniter似乎是用于创建Web页面或简单的Web应用程序,如博客一个伟大的工具。我的应用程序将是一个有点不同。很像uTorrent的WebUI中,我的web应用程序将是静态的在一个页面上,有阿贾克斯执行所有下的覆盖操作。这似乎有点尴尬使用codeigniter这样一个项目。

I may have failed to emphasize just how heavily Ajax based this web application will be. Codeigniter seems like a great tool for creating web pages or simple web applications such as a blog. My application will be a little different. Much like the uTorrent WebUI, my web application will be static on one page, having Ajax performing all the under-the-cover actions. It seems a little awkward to use Codeigniter for such a project.

是否有不同的架构,这种应用考虑在那里创造的呢?

Is there a different architecture out there created with this kind of application in mind?

推荐答案

你有没有考虑使用框架,如codeigniter?你熟悉任何类型的设计模式,如MVC?这两项将有助于在项目规定的文件的逻辑位置和分离。

Have you considered using a framework such as Codeigniter? Are you familiar with any sort of design patterns, such as MVC? Both of those would help dictate the location of files and separation of logic in your project.

编辑:codeigniter使用MVC,这只是用于网页编程的一个伟大的格局。看看这两个视频他们的教程。结合仅需30分钟左右,绝对充满了很好的了解,无论是作为一起来看看他们的理论框架的运作方式,以及由它们的文件夹结构提供的洞察力。

Codeigniter uses MVC, which is just a great pattern for web programming. Check out these two videos they have for tutorials. Only about 30 minutes combined, and definitely full of good knowledge, both as a look at the way their framework works, as well as the insight offered by their folder structure.

EDIT2: HTTP://$c$cigniter.com/tutorials

这篇关于我如何组织我的PHP项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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