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.php
file, which serves as the entry point for the application.
- Contains the main
-
.config
Directory:- Contains configuration files for the framework.
- Includes
_404.php
for handling 404 errors and_init.php
for initializing the framework.
-
serve
Directory:- Contains essential framework files, including classes and utilities.
- Includes
Apiconn.php
,Router.php
, andSource.php
for handling API connections, routing, and source management, respectively.
dangerDo not edit the codes inside the files present in the
server
directory without clear understanding of them, as it may modify the functionality of the Classes, and may result in unexpected behaviour in the API Server. -
source
Directory:- Intended for storing source files used by the application.
- Developers can add their source files here.
-
static
Directory:- Reserved for storing static files, such as CSS, JavaScript, or images.
Guidelines for Developers:
-
Routing: Developers can define routing rules in
index.php
to manage incoming requests. -
Source Files: Store source files (e.g., PHP scripts) in the
source
directory. -
Static Files: Place static files (e.g., CSS, JavaScript) in the
static
directory. -
.htaccess File: Phlame provides a
.htaccess
file to enable routing and restrict direct access to thesource
directory. For security purposes, developers are advised not to modify the.htaccess
file 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.