Welcome Guest, Not a member yet? Register   Sign In
COMPOSER_PATH error on multi app
#1

Hi all.

I've try to develop multi app using one Installation. Public folder, vendor folder, tests folder, writeable folder, etc, is used by all apps. Just app folder and .env file I put into different folder. So the folder structure like image below.

Code:
/_bar
  /app
  .env
/_foo
  /app
  .env
/public
/tests
/vendor
/writeable
composer.json
composer.lock
spark


This is the code on spark file line 44
Code:
require realpath('_bar/app/Config/Paths.php') ?: '_bar/app/Config/Paths.php';

This is the code on public/index.php line 15 - 66

Code:
$location = (substr($_SERVER['HTTP_HOST'], 0, 9) == 'localhost') ? 'local' : 'hosting';
defined('LOKASI') || define('LOKASI', $location);

switch ($location) {
    case 'local':
        switch ($_SERVER['SERVER_PORT']) {
            case '8081':
                $apl = 'bar';
                break;

            default:
                $apl = 'foo';
                break;
        }
        break;

    default:
        $domain = $_SERVER['HTTP_HOST'];
        $subdomain = explode('.', $domain)[0];
        switch ($subdomain) {
            case 'www':
                $apl = 'foo';
                break;

            case 'sub':
                $apl = 'bar';
                break;

            default:
                $apl = 'foo';
                break;
        }
        break;
}

require realpath(FCPATH . '../_' . $apl . '/app/Config/Paths.php') ?: FCPATH . '../_' . $apl . '/app/Config/Paths.php';

It's work, but composer didn't load

If I change the COMPOSER_PATH on Constants file

This is the code for _bar/app/Config/Constants.php line 26
Code:
defined('COMPOSER_PATH') || define('COMPOSER_PATH', ROOTPATH . '../vendor/autoload.php');

I got error:
Code:
Fatal error: Uncaught Error: Class 'Config\App' not found in D:\_DEV\PHP - CI4\multiapp\vendor\codeigniter4\framework\system\bootstrap.php:158 Stack trace: #0 D:\_DEV\PHP - CI4\multiapp\public\index.php(73): require() #1 D:\_DEV\PHP - CI4\multiapp\vendor\codeigniter4\framework\system\Commands\Server\rewrite.php(45): require_once('D:\\_DEV\\PHP - C...') #2 {main} thrown in D:\_DEV\PHP - CI4\multiapp\vendor\codeigniter4\framework\system\bootstrap.php on line 158

Full code on my github: https://github.com/itutu-media/multiapp

Please help.

Regards,
Itutu Media
Reply




Theme © iAndrew 2016 - Forum software by © MyBB