Phlame Directory Structure
Phlame is a microframework that comes with a default directory structure to help developers organize their projects efficiently. Let's explore the default directory structure and guidelines for using Phlame:
Directory Structure
root:.
│ index.php
│
├───.config
│ _404.php
│ _init.php
│
├───serve
│ Apiconn.php
│ Router.php
│ Source.php
│
├───source
│ index.src.php
│
└───static
Directory Structure Overview:
-
Root Directory (
./):- Contains the main
index.phpfile, which serves as the entry point for the application.
- Contains the main
-
.configDirectory:- Contains configuration files for the framework.
- Includes
_404.phpfor handling 404 errors and_init.phpfor initializing the framework.
-
serveDirectory:- Contains essential framework files, including classes and utilities.
- Includes
Apiconn.php,Router.php, andSource.phpfor handling API connections, routing, and source management, respectively.
dangerDo not edit the codes inside the files present in the
serverdirectory without clear understanding of them, as it may modify the functionality of the Classes, and may result in unexpected behaviour in the API Server. -
sourceDirectory:- Intended for storing source files used by the application.
- Developers can add their source files here.
-
staticDirectory:- Reserved for storing static files, such as CSS, JavaScript, or images.
Guidelines for Developers:
-
Routing: Developers can define routing rules in
index.phpto manage incoming requests. -
Source Files: Store source files (e.g., PHP scripts) in the
sourcedirectory. -
Static Files: Place static files (e.g., CSS, JavaScript) in the
staticdirectory. -
.htaccess File: Phlame provides a
.htaccessfile to enable routing and restrict direct access to thesourcedirectory. For security purposes, developers are advised not to modify the.htaccessfile directly.
Default .htaccess Configuration:
<IfModule mod_rewrite.c>
# Enable RewriteEngine
RewriteEngine On
# Set RewriteBase if your application is not in the root directory
# RewriteBase /
# Block direct access to the source directory
RewriteRule ^source/ - [F]
# Route requests to index.php for processing
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
</IfModule>
Without .htaccess many servers will not allow Routing, make sure you have .htaccess, if not, you can use the code provided above.