Welcome Guest, Not a member yet? Register   Sign In
Multi applications with same app folder but different configurations
#1

(This post was last modified: 11-17-2022, 07:27 AM by serialkiller.)

I need to have a system with a single app folder but multiple applications that use it
I started from the example found in the guide: https://codeigniter4.github.io/CodeIgnit..._apps.html

The structure represented in the example is:

foo/
    app/
    public/
    tests/
    writable/
    env
    phpunit.xml.dist
    spark
bar/
    app/
    public/
    tests/
    writable/
    env
    phpunit.xml.dist
    spark
vendor/
    autoload.php
    codeigniter4/framework/
composer.json
composer.lock

In my case, however, I want to achieve something a little different, not having an app folder for each application, but one for all applications like this:

app/

foo/
    public/
    tests/
    writable/
    env
    phpunit.xml.dist
    preload.php
    spark
    builds
bar/
    public/
    tests/
    writable/
    env
    phpunit.xml.dist
    preload.php
    spark
    builds
vendor/
    autoload.php
    codeigniter4/framework/
composer.json
composer.lock

To get this situation working I did some tweaks to change the pointer path correctly to the new app folder location

In Config/Paths.php
PHP Code:
public $systemDirectory __DIR__ '/../../vendor/codeigniter4/framework/system'

In foo/public/index.php and bar/public/index.php
PHP Code:
require FCPATH '../../app/Config/Paths.php'

In foo/spack and bar/spark
PHP Code:
require FCPATH '../../app/Config/Paths.php'

To get this to work I had to move the writable folder and the .env file to the same level as the app folder

Now I have the two apps working using the same app folder (in the future it will be more than two)

There are a number of things that I wish I could fix but I don't know how

1) Having the writable folder at the same level as the app folder, the various logs will all be inserted here and I will not have the distinction between the various applications, I know that the path of the logs can be changed, but to make them point to the specific application I should insert a variable in the path and I don't know how to do it

2) Same thing for the database, since it has to be different for each application I don't know how to dynamize this value

3) Same thing for $baseURL in the Config/App.php file, each application has its own and it's not the same for everyone

4) I use my own config file with a number of general setting variables, most are the same, but some are supposed to be different

The best thing for me would be to have my config file with some dynamic variables based on the application and use these values to set up the database for each application or to put the path to the writable folder inside its folder and so on.

The .env file could also stay at the same level as the app folder, use it for configurations that don't vary from application to application

In CI3 I have the working structure, but in CI4 many things have changed and I don't know how to reproduce the same situation

Could you help me get this structure working?
Reply


Messages In This Thread
Multi applications with same app folder but different configurations - by serialkiller - 11-17-2022, 07:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB