Welcome Guest, Not a member yet? Register   Sign In
Module not working on production
#1
Exclamation 

I follow some tutorials from web and put a module into my application.
Everything works fine on localhost (where the project run into a single folder), but when I send it to server (split it into ci4 and www (public folder)).
The home folder works fine, but when I visit site.com/admin for example I always receive 404, but when I run localhost/project/public/admin works fine.

app/config/autoload.php
PHP Code:
public $psr4 = [
 
APP_NAMESPACE => APPPATH// For custom app namespace
 
'Config' => APPPATH 'Config',
 
//'Admin' => APPPATH . 'Modules\Admin' 
 //'Admin' => ROOTPATH . 'Modules/Admin' //novo modulo
 
'Admin' => APPPATH 'Modules/Admin' //novo modulo
 
]; 

app/config/routes.php
PHP Code:
$routes->group('admin', ['namespace' => 'App\Modules\Admin\Controllers'], function ($routes) {
$routes->add('/''AdminController::index');
$routes->add('login''AdminController::login');
$routes->post('login''AdminController::login');
$routes->add('logoff''AdminController::logoff');
//etc... 

And the httaccess on www folder has the rule (again, on locahost works fine)
Code:
    RewriteCond %{REQUEST_URI} admin
    RewriteRule ^(.*)$ index.php?/$1 [L]
I'm thinking if the problem is related with some Apache's rule that I cannot config (production is a shared server)

Any idea ?
Mauricio Cunha
www.mcunha98.com
Reply
#2

I have shared hosting and mine is public_html. I setup an ftp user and password and just upload everyting to the root
and it just works fine for ftp I use FileZilla.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

@InsiteFX in my case unfortunatelly not work.
But the greate point is the documentation about modules (structure on project) is very simple and give a good direction, but when you go to production, the scenario has differences about the directives.
A good point for the documentation about this section is give more information about the server requirements or possiblity of conflicts .
In my local machine probably I did some configuration on apache, but on shared hosts not so easy, and probably the answer is on httaccess....
Mauricio Cunha
www.mcunha98.com
Reply
#4

Make sure the folder name is exactly like in Autoload.php (upper/lower case), and the location should be in ROOTPATH, not APPPATH (outside of /app/)
PHP Code:
'Admin' => ROOTPATH 'Modules/Admin' 

Make sure you have the right path for  your app installation in index.php
PHP Code:
$pathsConfig FCPATH '../your-app/app/Config/Paths.php';
// ^^^ Change this if you move your application folder 
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply




Theme © iAndrew 2016 - Forum software by © MyBB