CodeIgniter Forums
Controllers not loading, no logging either - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Controllers not loading, no logging either (/showthread.php?tid=68132)

Pages: 1 2


Controllers not loading, no logging either - Kaosweaver - 05-30-2017

Downloaded the latest code, uploaded it to my server and everything loaded (yeah!) no more ENV issues or logger loading issues.

I copied the home controller to pages.php and loaded it up in a browser and I get a 404 error - and - the URL changes from /pages to /public/pages
I try to load the checks controller and I get a 404 error and the URL changes from /checks to /public/checks

I check out the routes.php in the config folder and add:
$routes->add('/pages', 'Pages::index');

Try again, same result.

Apart from changing the App.php in the config folder for the $baseURL, nothing else was changed. Also, changed the logging to 9, however, no log file is being written (the writable folder's permissions are 777)

No errors on the server either.


RE: Controllers not loading, no logging either - Martin7483 - 05-30-2017

What do you have in your htaccess file?
How is your config setup?


RE: Controllers not loading, no logging either - Kaosweaver - 05-30-2017

the htaccess is identical to the default one in the repository
the config is identical to the default one in the repository (plus the baseURL change)

I literally downloaded the repository, changed the baseURL and uploaded it. The four steps in the installation documentation here:
https://bcit-ci.github.io/CodeIgniter4/installation/index.html
(well 3, while I do have a database, I figure, one step at a time)


RE: Controllers not loading, no logging either - InsiteFX - 05-30-2017

Did you set your paths up in the .application/config/paths.php

That's were the public directory is set.


RE: Controllers not loading, no logging either - kilishan - 05-30-2017

Try removing the leading slash from the route. It's a known bug that I haven't had a chance to fix, yet:

Code:
$routes->add('pages', 'Pages::index');



RE: Controllers not loading, no logging either - Kaosweaver - 05-30-2017

The paths.php file was not changed. the paths on the server match the paths in the paths.php file.
I'm getting a CI error (not a generic 404) - CI is loading, the system dies in the startController where the $this->controller value is "Public". Specifically, it dies at line 373
Code:
throw new PageNotFoundException('Controller or its method is not found.');



RE: Controllers not loading, no logging either - Kaosweaver - 05-30-2017

Changed the routes to remove the leading / and then attempted the URL as /pages and /pages/

The result is still the same, the URL changes to /public/pages (for both)
while the default root URL still loads.


RE: Controllers not loading, no logging either - kilishan - 05-30-2017

Oh! Completely missed one part of your original post. You need to point your domain to the public directory in the CI repository. Currently, it looks like it's pointing to the main directory (with application and system as sub-directories). That's not how CI4 is designed to work for a security best practice. Point the domain to the public folder and you should be good.


RE: Controllers not loading, no logging either - Kaosweaver - 05-30-2017

(05-30-2017, 11:59 AM)kilishan Wrote: Oh! Completely missed one part of your original post. You need to point your domain to the public directory in the CI repository. Currently, it looks like it's pointing to the main directory (with application and system as sub-directories). That's not how CI4 is designed to work for a security best practice.  Point the domain to the public folder and you should be good.

It is (and was prior)
[Image: img.png]
In fact the above image's URL is http://ci4.kaosweaver.com/img.png and if you go to http://ci4.kaosweaver.com/ you see the welcome message.


RE: Controllers not loading, no logging either - kilishan - 06-02-2017

Sorry it took me a while to get back here. I've been completely slammed against a deadline (which I just wrapped up, yay!).

Trying to follow your steps:

- I pulled down the latest code
- Copied Controllers/Home.php to Controllers/Pages.php
- Renamed the the class to Pages in the new file
- Made the index method output something different so I knew I was there.
- fired up the local server (php serve.php) and visited localhost:8080/pages in my browser and what I expected showed up. I noticed if I try /pages on your site it works as expected currently, too.

Since that worked, I tried adding the same route that you had ($routes->add('/pages', 'Pages::index')Wink and things still work for me.

Finally, realizing I hadn't set my path, I went and edited Configi/App.php and set base_url to 'http://localhost:8080'. That finally gave me the standard Whoops! error. So, I create a simple .env file with a single line (CI_ENVIRONMENT=development) so that I could see the actual error, and it's throwing an error with CodeIgniter\HTTP\URI::resolveRelativeURI() .

But that's the only error I could get it to create (and I need to go figure out why now....) Your site seems to be working. What did you figure out for you?