PHP framework (HMVC, global context, ORM...)

Ok I will download again when I am back on my desktop,

May I suggest looking at the CodeIgniter4 installation and especially their setup because it seems to be following the latest tried and preferred layout/ installation methods

Simplified it consists of four basic parts.

  1. read only versioned system folder recommended to store above the root.

  2. writable folder recommended to store above the root. Used for logs, uploads, etc

  3. read only application recommended to be stored above the root. Used for Controllers, Models, Views, etc

  4. read only index.php file stored in public folder with symlinks to system and application folders. File can be copied and renamed with symlinks to different system folders and/or different application folders,

This container layout makes it easy to update a single system folder and to have a temporary development application folder which can be easily switched using symlinks. Also the common system folder can be shared between multiple applications.

Complex (module-based) web-project on GI consists from three types of objects:

  1. Framework itself - folder GI. Above the root
  2. Modules. In test-project I have four: Core, Home, Prime, Blog. Also above the root.
  3. Host root dir ordinary called “public” or “webroot”. In this folder there are .htaccess file and index file, also there automatically created “symlinks” dir.

So…

There is no predefined structure. Folders of all three types could be allocated by developer’s decision.

Framework and modules bound to index.php with standard framework autoloader or with composer. Absolutely no problem - to use framework or some module in few projects.

A project needs no specific settings except of virtual host with root dir and autoloadig (see prev.).

1 Like

SUCCESS… but not without minor problems.

  1. /gi-master/project.complex/webroot following errors generated…
    “must be writable in order for symlinks folder to be created”
    a. applied PHP chmod -R 0777 gi-master/project-.complex/webroot
    b. now successful

  2. moved GI to above-the-root and following error generated:
    ‘/var/www/above-the-root/GI/FileSystem/Symlink/Symlink.php’ on line 66
    Error number 2
    Error message: 'symlink(): No such file or directory

  3. renamed GI to GI-ver-002 - following errors
    Fired error on ‘/var/www/example.com/public_html/gi-frame/gi-master/GI-ver-002/FileSystem/Symlink/Symlink.php’ on line 66
    Error number 2
    Error message: ‘symlink(): No such file or directory’

I would prefer a writable directory above-the-root for the symlinks directory.

@igor_g

Further info:

In accordance with your post: #40

I created a VirtualHost ServerName my-server.localhost and was able to load the application.

I was unable to load: the following:

  1. http://my-server.localhost/index.php
  2. http://localhost/path/to/project.complex/webroot/
  3. http://localhost/path/to/project.complex/webroot/index.php

I modified project.complex/webroot/index.php:

<?php
use GI\Application\Application\Complex\Application;
use GI\Autoloader\Autoloader;
use Core\Module\Providers;

# MAYBE localhost
	$ok = 'localhost'===$_SERVER['SERVER_NAME'];
	if( $ok ) :
		header('Location: http://my-server.localhost');
		exit;
		// REDIRECTION WORKS OK
	endif;	

require_once dirname(dirname(__DIR__)) . '/GI/Autoloader/resources.php';


I do not understand the benefits of using a VirtualHost and would be grateful for an explanation.

I would far prefer using my current localhost setup especially since I would like to try the Framework on my server. I do not want to create a Remote Server VirtualHost because the current server configuration is working OK and i am reluctant to make any changes.

  1. “symlinks” created with 0777 (GI\Application\Call\Web\Call - line 274).

  2. Try just to reload site by this error. Yet I see no reason of it. What is not found? Source? But it was checked. Target dir? It should be created.

Actually this not obligatory. But this just comfortable.

There were filled permission errors. I did not have access rights.

Okey, “symlinks” should to have 0777. Intermedial dirs - also 0777:

        if (!file_exists($target)) {
            if (!is_dir(dirname($target))) {
                mkdir(dirname($target), 0777, true);
            }

            symlink($source, $target);
        }
1 Like

Sorry if I’m going off-topic, but when I see code granting full permissions (u, g, o - r, w, x) it gives me pause.

Is there any reason the permissions need to be full?

So… I placed my demo project on external hoster. This hoster automatically creates dirs with 0755. If I try create 0744 - symlinks not readable.

In module Blog added usecase User Statistic - by click on user login.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.