简体   繁体   English

组织php项目文件

[英]Organize php project files

I'm new to the web development, recently I create a web application with Php/Mysql, and now I want to put it on to the server but I feel that my files organization is bad (very bad). 我是网络开发的新手,最近我用Php / Mysql创建了一个Web应用程序,现在我想把它放到服务器上,但我觉得我的文件组织很糟糕(非常糟糕)。

my project files structure looks something like that 我的项目文件结构看起来像那样

|--XAMPP htdocs
    |--MyProject
        |--config.php
        |--functions.php
        |--header.php
        |--nav.php
        |--index.php
        |--js   
        |--css
        |--images
        |--register
            |--index.php
        |--messages
            |--inbox
                |--index.php
                |--handle_inbox.php
            |--outbox
                |--index.php
                |--handle_outbox.php
            |--trash
                |--index.php
                |--handle_trash.php
            |--uploaded_files
        |-- ...

what I can do to improve this structure and make it secure ?! 我能做些什么来改善这种结构并使其安全?

Paul M. Jones has done some fantastic research into common practice of tens of thousands of github projects in the realm of PHP. Paul M. Jones对PHP领域数以万计的github项目的常规实践做了一些很棒的研究。 He has compiled a standard filesystem structure based on this research. 他根据这项研究编制了一个标准的文件系统结构。 Take a look at the Standard PHP Package Skeleton and base your project off of it. 看一下标准PHP包骨架,并将您的项目基于它。

You do not need all of the file structure that he recommends, but it's a great place to start. 您不需要他推荐的所有文件结构,但它是一个很好的起点。 If you are planning to open-source your project, this file structure will make the most sense to your potential contributors and users. 如果您计划开源项目,这个文件结构将对您的潜在贡献者和用户最有意义。

The recommendation would be to have all the script "hidden" from straight access, and to have separately public directory. 建议将所有脚本“隐藏”为直接访问,并具有单独的公共目录。

You may check the best practices from different frameworks, how they organize the directories: 您可以检查来自不同框架的最佳实践,它们如何组织目录:

I'd recommend to guide these best practices, as they came to this through the long way and tons of tries. 我建议引导这些最佳实践,因为他们通过漫长的方式和大量尝试来实现这一目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM