Development - File Structure for standard application
Below the File Structure for standard application:
-
assets/ directory where placed all asset files
-
minified/ directory for storing minified files
-
css/ CSS minified files
-
js/ JS minified files
-
modules/ directory for storing application modules
-
vendors/ directory for storing vendor files
-
images/ directory where placed all public images
-
css/ directory where placed all public css files
-
js/ directory where placed all public javascript files
-
protected/ directory where placed all files of applications
-
components/ directory for storing application component files
-
config/ directory for storing configuration files
- main.php main configuration file
- db.php database configuration file
-
controllers/ directory for storing cotroller classes
- ErrorController.php ErrorController class
- IndexController.php IndexController class
-
data/ containing the sample database
- config.db.tpl template for database configuration file
- config.main.tpl template for main configuration file
- schema.mysql.sql DB schema for MySQL database installation
- schema.update.mysql.sql DB schema for MySQL database update
-
entities/ directory for storing entity files
-
messages/ directory for storing messages
-
en/ English translation
- app.php main translation file for application
-
models/ directory for storing model classes
- Login.php Login model class
-
modules/ directory for storing modules files
-
tmp/ directory for storing temporary files
-
backups/ directory for backup files
-
cache/ directory for cache files
-
logs/ directory for log files
-
views/ directory for storing view classes
-
index/ Index view directory
- index.php Index/index view file
- .htaccess protected folder .haccess file
-
templates/ directory where placed all templates
- default/ all public files for a specific template
- css css files for template
- images image files for template
- js javascript files for template
- default.php default (master) template file
- .htaccess templates directory .haccess file
- .htaccess application .haccess file
- index.php application entry point
protected/.htaccess
- htaccess file denies access to protected directory from all ¶
deny from all
templates/.htaccess
- htaccess file denies access to all PHP files in templates directory ¶
<FILES ~ "\.php$">
order allow,deny
deny from all
</FILES>
.htaccess
- htaccess file converts all requests into url parameter and perform following directives ¶
# Rewrite URL rules
<IfModule mod_rewrite.c>
RewriteEngine On
# Exclude images from rewriting rules
RewriteCond %{REQUEST_URI} !(\.gif|\.jpg|\.jpeg|\.png|\.bmp)$ [NC]
# Exclude fonts from rewriting rules
RewriteCond %{REQUEST_URI} !(\.eot|\.woff|\.woff2|\.svg)$ [NC]
# Exclude css files from rewriting rules
RewriteCond %{REQUEST_URI} !(\.css)$ [NC]
# Exclude Javascript files from rewriting rules
RewriteCond %{REQUEST_URI} !(\.js)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
# Error document
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
Options All -Indexes
index.php
- main HTTP request dispatcher file ¶
// Change the following paths if necessary
defined('APPHP_PATH') || define('APPHP_PATH', dirname(__FILE__));
// Directory separator
defined('DS') || define('DS', DIRECTORY_SEPARATOR);
// Production | debug | demo | test | hidden
defined('APPHP_MODE') or define('APPHP_MODE', 'debug');
$apphp = dirname(__FILE__).'/../../framework/Apphp.php';
$config = APPHP_PATH.'/protected/config/';
require_once($apphp);
A::init($config)->run();