Reputation: 1129
I have one website, let's call it www.main.com, which is located on the server at /home4/username/public_html/main. This site is running Phalcon PHP with no issues at all.
Now I have made a subdomain, let's call it test.main.com, and used cPanel to set the route for the subdomain to /home4/username/testsite/test. This is where the problem is.
Both /public_html and /testsite have their own .htaccess files containing the following:
test site:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ test/public/ [L]
RewriteRule ((?s).*) test/public/$1 [L]
</IfModule>
main site:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ main/public/ [L]
RewriteRule ((?s).*) main/public/$1 [L]
</IfModule>
And testing the test site locally via XAMPP it works fine (currently just a very VERY simple Phalcon test page). But when I upload the exact same site to the server phalcon errors with:
PhalconException: IndexController handler class cannot be loaded
The dispatch index.php file for the (non-working) test subdomain site contains the following:
<?php
try {
//Register an autoloader
$loader = new \Phalcon\Loader();
$loader->registerDirs(array(
'../app/controllers/',
'../app/models/'
))->register();
//Create a DI
$di = new Phalcon\DI\FactoryDefault();
//Setup the view component
$di->set('view', function(){
$view = new \Phalcon\Mvc\View();
$view->setViewsDir('../app/views/');
return $view;
});
//Setup a base URI
$di->set('url', function(){
$url = new \Phalcon\Mvc\Url();
$url->setBaseUri('/test/');
return $url;
});
//Handle the request
$application = new \Phalcon\Mvc\Application($di);
echo $application->handle()->getContent();
} catch(\Phalcon\Exception $e) {
echo "PhalconException: ", $e->getMessage();
echo "<br /><br /><strong>Trace Stack</strong>: ", $e->getTraceAsString();
}
Now this is baffling, as I said, there's no reason code wise the Phalcon project is wrong, as it works fine locally. So the only thing I can think of is somehow the routing of the subdomain is screwing things up, but I have no idea how, or how to fix it?
Upvotes: 0
Views: 367
Reputation: 1129
So it turned out to be something really simply stupid. For some reason using phalcon locally via XAMPP on Windows allowed me to use indexController.php
as a controller name. However, when uploaded to the Apache server the name needed to be capitalised in full camel case to IndexController.php
to work.
Upvotes: 0