问题
What is the best directory structures of an object oriented PHP project? taking security into consideration among the other factors. I usually use these technologies to build websites: OOP PHP/MySql, html, css, javascript/jQuery, ajax and smarty. And I don't want to use a framework right now.
回答1:
Just use namespaces with an autoloader.
This way you can organize your folders this way:
/
  src
    Model
      User.php
    View
      index.php
    Controller
     HomeController.php
  assets
    img
    js
    css
Your User class will be like:
namespace Model;
class User{ ... }
and you can refer to it this way:
$user = new \Model\User;
or:
<?php
use \Model\User;
...
// later in your code
$user = new User;
Where's the magic? When you ask for a class, the autoloader requires it [and throws an exception if anything goes wrong].
A basic autoloader will look like:
spl_autoload_register(function ($class) {
    include 'src' . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
});
It will search classes from src folder based on class name, in this case Model\User.
These are the basics, it's up to you to tweak it a bit.
回答2:
The best way is that the directory structure and file-organizing reflects the application so that it is accessible for development and operation.
来源:https://stackoverflow.com/questions/12572302/what-is-the-best-way-to-organize-files-and-folders-in-an-object-oriented-php-pro