|
|
|
Ask HN: PHP Directory structure and code organization
|
|
3 points
by joell
4248 days ago
|
|
I work for a company (PHP shop) where we are looking at cleaning/separating our code as we move toward PSR-0 (http://www.php-fig.org/psr/psr-0/). We have lots of different `features` that we would like to split up and organize in a way that makes the most sense. We want:
- Highly modular.
- Easily extend/implement abstract code between features.
- Outside the core framework. Any suggested reading material, advice, or feedback would be fantastic! Thanks HN! :) Edit: We use CodeIgniter (earlier version) |
|
/core/apps/[name of app]
/core/config/ (config files, PDF templates, etc.)
/core/inc/ [libraries/extensions]
/public_html/index.php
/public_html/info/ [icons, images, and other public accessible data]
mainly index.php has
$home = $_SERVER['SCRIPT_FILENAME'];
$loc = explode('/',$home);
define('CORE_BASE', implode('/',array_slice($loc,0,-2)).'/');
require_once core_BASE.'core/inc/main.php';
which defines the core path (below web root), then includes the main base code. From there all code is below web root.
note: css and javascript can be included directly (saves having browser request them anyway)