-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Documentation out of date? discoverLocal() #581
Comments
That config value will search for other
Then, in that What errors are you seeing? |
Definitely let us know the error you're experiencing otherwise it's hard to help. Additionally - ensure you have the latest CI4 code as that feature was only added late last week. If your code is not up to date, you'll hit an error that the method doesn't exist. |
Thanks, I have just done a pull of the latest code to ensure that I was on the latest code. When I add this line to my application/Config/Routes.php file.
I get a the "Whoops! We seem to have hit a snag. Please try again later..." Page. Without this line I cannot get any controller to work outside of the application/Controllers/ directory. What I have done so far is as follows;
I get a 404 error; Up until now I have used CI3 with HMVC so am not accustomed to namespaces yet. I am probably doing something really really stupid. Thank you for your patience. |
At a glance it looks correct. The only thing I can see as a possibility currently is that in
I thought that got automatically cleaned up but it's possible that's causing an issue. Please give that a try and let me know. |
@karlgray did that change work for you? Or did you find something else that worked? |
Taking another look at this and your error is the namespace of your Blog controller. Should be:
Basically, namespaces (with the autoloader) tell which directories to traverse to find the class in. |
I am sorry for delay in responding. I have changed the controller to this;
I am still getting a 404 :( |
I have totally cleared out the install and started from scratch. I done a fresh git clone. In /Blog/Controllers/Blog.php I have
In /Blog/Config/Autoload.php I have update the $prs4 to this;
in /Blog/Config/Routes.php i have this;
I have made no other changes to any other files. I must be doing some seriously dumb I guess :( |
Biggest thing I see is that you forgot to tell CodeIgniter where the Blog namespace lives. You added the namespace to Blog/Config/Autoload instead of application/Config/Autoload. Unless you just mis-typed? |
Thanks, Yes I had done this correctly but mis-quoted above. I have edited my previous post to reflect this. |
I am still concerned/Confused by the documentation. In the Routes section it says the following;
However there is no mention of $routes->discoverLocal(true); in /application/Config/Routes.php Has this call been changed/removed? Or is the manual out of date? |
The docs are correct. And It's true there's nothing in that docblock. Heck, I'm thinking of removing most of that docblock because it takes up so much space. :) If all you're seeing is a "Whoops" screen, you should set your environment to development so that you can see the errors that are popping up. That should help out. With any luck, it's simply a typo in your controller. Also, I don't know if it's just the example, but it looks like you might have your routes above the declaration of $routes in the routes file? Though, I'm guessing you just stripped those out to show me. And, finally - to check out a working example, take a look at my Simple Forums repo. |
I will look at your example. Thank you :) I get the whoops screen when I add the line; On the $routes setting. I mistyped as well. I have updated my error there.
I have not changed anything in /application/Config/Routes.php Apologies for any confusion on that. I will go look at your example now. Thanks. |
Strange. I just went to re-add the $routes->discoverLocal(true); to my Routes.php file and saw it was already there but set to false. changed it to true and it all works. I am seriously confused by why it wasn't there on my previous pull and didn't work when I added it manually and now does. However... As it works now I am not going to worry myself about it. Thank you very much for looking into this for me and putting up with my daft questions. |
No worries! Glad you got it working. |
I think the documentation is not clear... Look at discoverRoutes() method, and their inside call to file locator search: $this->fileLocator->search('Config/Routes.php'); Inside search method, there are "if (file_exists($folder . $path))", where $folder is "/workspace/CodeIgniter4/acme/" and path "Config/Routes.php". Is this the correct behaviour or there's something else to do?
Putting "Config/Routes.php" inside acme directory has working. |
It searches for the Where do you think that needs to be made clearer? |
I read the documentation and find what you said. But now I have another question, what is the purpose to have two routes configurations? Sorry for my carelessness :) |
Sorry, I don't understand the question. The module is Either way - this is not a bug. Please take other support questions to the forums :) |
Sorry, maybe my english is not good enough, I will discuss it on the forum if I need something else. Thanks :) |
I am trying to get modules to work using the documentation here;
https://bcit-ci.github.io/CodeIgniter4/general/modules.html
In the Routes section It mentions,
$routes->discoverLocal(true);
This causes errors and I cannot find reference to this in the source.
Is the documentation out of date or am I being an idiot?
The text was updated successfully, but these errors were encountered: