Skip to main content

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:

  1. Root Directory (./):

    • Contains the main index.php file, which serves as the entry point for the application.
  2. .config Directory:

    • Contains configuration files for the framework.
    • Includes _404.php for handling 404 errors and _init.php for initializing the framework.
  3. serve Directory:

    • Contains essential framework files, including classes and utilities.
    • Includes Apiconn.php, Router.php, and Source.php for handling API connections, routing, and source management, respectively.
    danger

    Do 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.

  4. source Directory:

    • Intended for storing source files used by the application.
    • Developers can add their source files here.
  5. 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 the source 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>
caution

Without .htaccess many servers will not allow Routing, make sure you have .htaccess, if not, you can use the code provided above.