What is the purpose of the system directory of the Inphinit micro-framework?

5

I intend to use the Inphinit micro-framework in my project, but first of all I need to know more about it.

So, I created an example project just to familiarize myself with its features, however, I had a question about a directory it has, which is the system directory. See below its structure:

C:\XAMPP\HTDOCS\HELLOINPHINIT\SYSTEM
├───application
│   ├───Config
│   ├───Controller
│   │   └───Users
│   ├───Model
│   └───View
│       ├───debug
│       └───foo
├───boot
└───vendor
    ├───composer
    └───inphinit
        └───framework
            └───src
                ├───Experimental
                │   └───Routing
                └───Inphinit
                    └───Routing

Above are the directories and subdirectories of the system directory.

Question

I would like to know what is the purpose of the system directory and how important is it to my web application?

    
asked by anonymous 24.12.2016 / 02:26

1 answer

5

The framework is mine and really has reason for everything in how it was done, unfortunately I have not yet had the time to document it in a way that can make it useful, I will try not to delay in the explanation and according to the time I will edit to add details.

How other frameworks work

To explain why the structure is this:

./public_html
  ├───index.php
  └───system
      ├───application
      ├───vendor
      └───boot

You need to understand how other frameworks work, most of them use a directory within the project folder called ./public (laravel) or ./webroot (cakephp). This requires that at the time of publishing an online project the developer / administrator points to folder these folders as the root of the site, this is sometimes laborious and sometimes on more limited servers like the shared servers it is necessary to move the content to public_html and get the rest of the content and put it away, which may possibly confuse a bit for those who have no experience.

Of course, just follow the guidance on the websites that have the documentation, but I still notice a lot of people having trouble with it.

How Structure Works

My idea in the framework was that you could easily move content from one place to another without having to adjust anything, so the structure looked like this:

./home/user/public_html
 ├───index.php # Arquivo principal que inicia tudo
 └───system # Pasta aonde ficarão os dados e funcionalidades
     ├───application # Pasta dos Controllers, Models e Views
     ├───vendor # Pasta aonde fica o nucleo do framework e frameworks de terceiros instalados via composer
     └───boot # arquivos de inicialização da aplicação, "cache" dos namespaces
Some may ask that leaving the system folder within public_html and www may be insecure, in many cases this would be really correct, but the system uses routes and ignores access to ./system folder, I asked a few questions about security, locks and / or attempts to cause some flaws, basically .htaccess looks like this:

RewriteRule "^system/" "index.php" [L]

And if mod_rewrite is disabled then apache will issue the error% with_%.

There is still the 500 Internal Error Server folder containing any data type used in the application, in like-unix environments, it still forces system/storage as permission :

$r = is_dir($fullName) ? true : mkdir($fullName, 0600, true);

The whole idea is to simplify the understanding to the maximum of who is starting, for example, instead of adding the settings of routes in a file in a subfolder I tried to leave free to develop as you want within two files the 0600 and system/main.php , main.php is the main project file next to the controllers and views, dev.php is only used if it is in development mode.

At first I thought about doing something like:

  ./home/user/public_html
    ├───index.php
    ├───application
    ├───vendor
    └───boot

What would simplify, but I would have to do this in .htaccess:

RewriteRule "^(application|vendor|boot)/" "index.php" [L]

And also thought that maybe the developer could make some confusion between main.php and index.php, apart from the possibility that the developer believes that the folders are insecure and then move more easily every application without having to move a folder by one, doing something like this:

  ./home/user
    ├───system
    │   ├───main.php
    │   ├───vendor
    │   └───boot
    └───public_html
        └───index.php

And changing in the index.php the value of system/dev.php of:

define('INPHINIT_PATH', INPHINIT_ROOT . 'system/');

To:

define('INPHINIT_PATH', INPHINIT_ROOT . '../system/');

Summarizing

The folder INPHINIT_PATH is the real project and what is outside it is just what starts it, which can be ./system or server #

    

24.12.2016 / 03:12