Skip to content

setDefaultNamespace Sub directories #917

Description

@JakeAi

I'm not sure if I'm understanding this correctly or not but I merged two sites together. A external site and a dashboard and am splitting them up as so

application/Controllers/External
application/Controllers/Internal

My VHosts are setup as:

<VirtualHost *:80>
	ServerName www.external.com
	DocumentRoot "${INSTALL_DIR}/www/ci_app/public"

  SetEnv CI_APP "external"
  SetEnv CI_ENVIRONMENT "development"
  SetEnv app.baseURL "https://www.external.com/"

	<Directory "${INSTALL_DIR}/ci_app/public">
		Options Indexes FollowSymLinks MultiViews
		AllowOverride All
		#Require local
		Require all granted
	</Directory>
</VirtualHost>


<VirtualHost *:80>
	ServerName www.internal.com
	DocumentRoot "${INSTALL_DIR}/www/ci_app/public"

  SetEnv CI_APP "internal"
  SetEnv CI_ENVIRONMENT "development"
  SetEnv app.baseURL "https://www.internal.com/"

	<Directory "${INSTALL_DIR}/ci_app/public">
		Options Indexes FollowSymLinks MultiViews
		AllowOverride All
		#Require local
		Require all granted
	</Directory>
</VirtualHost>

My routes are setup as

$routes->setAutoRoute( true );

switch ($_SERVER['CI_APP']) {
	case 'external':
		$routes->setDefaultNamespace( 'App\Controllers\External' );
		break;
	case 'internal':
		$routes->setDefaultNamespace( 'App\Controllers\Internal' );
		break;
	default:
		die();
		break;
}

So in the File application/Controllers/External/About.php I have

<?php namespace App\Controllers\External;

class About extends Buffer {
	public function index() {
		echo 'works';
		die();
}
	//--------------------------------------------------------------------

}

This file gets routed fine. The problem is when I navigate to www.external.com/Shop/Products/Search. Products.php is inside a sub folder called "Shop". It triggers a 404 which doesn't make sense since the other one gets routed fine. The following file does not since it is in a sub directory. No controller gets loaded if it's in a sub folder. Is this correct behavior?

<?php namespace App\Controllers\External\Shop;

class Products extends Secure {
	public function __construct(RequestInterface $request, ResponseInterface $response) {
		parent::__construct( $request, $response );
	}

	public function index() {
		404
	}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions