steevedroz/nano-framework

1.4.1 2023-11-22 14:52 UTC

This package is not auto-updated.

Last update: 2024-04-24 17:14:39 UTC


README

DISCLAIMER: This is not a good Framework, its sole purpose is the teaching of the mechanisms behind a Framework. For example, the database is simply a bunch of JSON files that have to be completely rewritten each time a single value is edited. Please consider choosing a real framework if you intend to use this as a base for your website.

NanoFramework is an extremely tiny PHP Framework. Its source code holds in 6 classes and 1 dependency. The goal is to stay clear while learning by allowing the student to not be lost in hundreds of source files.

Installation

In order to install NanoFramework:

  • Create an empty folder on your computer, where your local server asks you to (usually a directory named www or htdocs).
  • From that folder, run the command composer require steevedroz/nano-framework (you may need to install composer beforehand).
  • Run the command vendor/bin/nano-generate, accept the override of composer.json.
  • Run the command composer dumpautoload to reload all the generated files.
  • Run the website and behold the first page!

Usage

This will explain the basic usage of the Framework. For a more in depth explanation, please consider visiting the doc.

MVC

NanoFramework uses the Model-View-Controller architecture.

The flow is the following:

  1. The server recieves a request to a URI.
  2. index.php is called, the route is analyzed.
  3. If the route is referenced in the file called routes, it is changed to its corresponding value.
  4. The route (maybe modified) represents the name of a Controller, the name of a method and parameters (parameters are optional, the method is index if not specified, only the Controller name is required).
  5. The corresponding method of the Controller is called.
  6. That method may call a Model, in order to obtain data from the database.
  7. That method may call a View, possibly passing it the data, in order to generate an HTML file.
  8. The method returns that file that is bubbled up to index.php and displayed on screen.