views:

72

answers:

3

I'm building my first PHP project, and am not sure where to put external libraries like doctrine. I could put them inside my app, making it easier to reference with a relative path:

myproject
   app
   public
   lib
      doctrine
   log

Or I could put them outside my project directory structure, making it easier to share between multiple projects:

myproject
   app
   public
   log
lib
   doctrine

Is there a standard or best practice for this?

+1  A: 

Code libraries in a non-Web-accessible path is preferred for security purposes. You can still reference them using relative paths, i.e. '../lib/' prefix.

stillstanding
+1  A: 

Put them where you can access them. /lib makes sense or /vendor but as long as they are accessible it is fine. If you got multiple domains running on one host sharing one library, you might want to keep this library outside these domains and just point your include_path to the library or symlink it.

Gordon
+1  A: 

I usually use something like this as a structure

db               <-- database delta scripts
dependencies     <-- own libraries
   3rdparty      <-- 3rd party stuff
protected        <-- all code
public_html      <-- HTML, css and javascript (also the entry script index.php)
Blizz