phpdeploymentyii2shared-hosting

Module controller do not work in yii2 deployment on shared hosting


I deployed my php/Yii2 project (based on the basic template) to a shared hosting webspace. I want to access the project via an subdomain because an wordpress is running on the main domain. The normal controllers of the base project are working fine. The problem is that the framework can't find any controller that is in a module. The module itsef is registered properly.

The folder structure in the webspace is the following:

The modules are configured like this:

'modules' => [
    'testmodule' => [
        'class' => 'app\modules\testmodule\Module',
    ],
],

The UrlManager is configured like this:

[
    'showScriptName' => false,
    'enablePrettyUrl' => true,
    'enableStrictParsing' => false,
    'rules' => array(
        '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
        '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
        '<module:\w+>/<controller:\w+>/<action:\w+>/<id:\d+>' => '<module>/<controller>/<action>',
        '<module:\w+>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>'
    ),
];

The .htaccess file in the _project\web looks like this:

Options +FollowSymLinks
IndexIgnore */*

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /index.php? [L]

In the _project folder I do not have an .htaccess file.

On my local machine everything is working fine. On my webspace the controllers of the project itself are working fine. As soon as I navigate in a module i get an 404 Error of the yii framework. I debugged the project and found out that the module itself is loaded correctly. The problem is that the framework can not find the Controller Class because the function class_exists(controller) returns false. I don’t have an idea what i can do to fix this. Hopefully somesone here can help me, thanks a lot!


Solution

  • thanks to the comment of Michal Hynčica! I wrote my controllers lower case and yii2 is looking for them with CamelCase. This worked on windows. But on my shared hosting based on this did not work because of Case-sensivity!