Directory & URL Structure of Ness PHP Framework


Directory Structure #top

Ness PHP's directory structure is not confusing. All folders and paths organised hierarchically and described clearly with folder names. You can clearly understand at a glance which folder is for what. Here is a short description for each folder available in Ness PHP project.





index.php: This file is the most important file of your application, we can call it entry point for your application. All configurations and url analyzes are made here for first time.
app_config.php: This files contains some configurations of your project
composer.json: Required for composer.

Ness: This folder contains core framework files and core framework code of the Ness PHP. You can use files in this path to extent the framework.
Application: All your project resources are available in this path. You can write your application's code in the required paths described below.
Application/Content: This folder contains some sub folders for some resources like; images, style sheets, javascript files, html widgets and file upload path for using with ContentManager class which is described in this documentation. You can use ContentManager for including each file type in your project with a single line of code.
Application/Config: This folder is used to store some user-created configuration files. You can create any class or variable in Config path then load to your app with Ness PHP's Library class.
Application/Language: Define language files for creating multilingual applications with help of Ness PHP Language helper class.
Application/Library: Sometimes you will need to use third party codes or your own classes. In this case you must put all third party libraries here to include them in your code. Ness PHP has a function to load libraries when you need.
Application/Model: Used to store 'Model' classes.
Application/Output: This folder contains 3 text files. This files are automatically generated by your code and holds the Errors, Warnings and output messages.
Application/Template: Ness PHP framework has a templating engine. if you want to avoid code repetition you can create a template and use them with your views. All your html templates must be located in this folder. Please read topic related to template engine for getting more.
Application/View: View files of your application must be in this folder. You can use sub folders to separate the parts of your website.
Application/Controller: All your controllers should be in this folder. When you make a request, according to your url the framework will find a controller to respond.
Information All folders contains an index.html file for preventing directory listing. Please do not forget to copy/paste an index.html file if you create a new directory in your project root.


URL Structure #top

Ness PHP framework generates URLs automatically by analyzing your controllers. There is no need to write Routes in Ness PHP. By this way you can gain time while your projects. Just create a controller and controller's actions for creating meaninful urls in Ness.
http://www.examplesite.com/ [controller] / [method] / [parameter]

Example Controller

<?php
use Ness\Controller as myController;

class indexController extends myController
{
    public function indexAction($param = 0)
    {
        $this->View->Render('startpage.php');        
    }

    public function printAction($param = 'Hello World')
    {
        $this->Content->Render("Hey your parameter is; {$param}");
    }
}
                                
If we navigate to http://www.examplesite.com/ or http://www.examplesite.com/index the indexAction runs. If we navigate to http://www.examplesite.com/print the output will Hey your parameter is;, if we navigate to http://www.examplesite.com/print/hello the output will; Hey your parameter is; hello