Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setDefaultNamespace Sub directories #917

Closed
JakeAi opened this issue Jan 31, 2018 · 1 comment
Closed

setDefaultNamespace Sub directories #917

JakeAi opened this issue Jan 31, 2018 · 1 comment

Comments

@JakeAi
Copy link
Contributor

JakeAi commented Jan 31, 2018

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
	}
}
@lonnieezell
Copy link
Member

What you didn't show, is what the route you setup for shop/products is. That is where the error is, likely.

However, this isn't a bug from what I can tell, so please continue this discussion on the forums as we reserve the Issues tracking for actual bugs and feature planning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants