I finally got a basic framework set up and working, however now when I wish to add an action in the 'IndexController.php', it doesn't seem to be working.
I used the following terminal command to add an "about" action:
zf create action about index
It appears that worked, as I opened 'IndexController.php' back up and the new action function is there. And a corresponding 'about.phtml' file was created in 'views/scripts/index', alongside 'index.phtml' that was already there.
When I access the index at
http://localhost3:8888/
the page opens properly.
However if I now try to access the about page at
http://localhost3:8888/index/about
I get a "404 not found" error.
Any ideas?
Looks like a mod_rewrite problem.
Try http://localhost3:8888/index.php/index/about. If it works, then it definitely means that mod_rewrite wasn't correctly set up.
Related
I want to create a template for page not found. whenever 404 no route found exception is throwing need to redirect to page. As that is not in proper UI way. I tried steps from this URL
https://symfony.com/doc/current/controller/error_pages.html
I am new to symfony . followed steps until service.yml and created customExceptionController.php and I dont know what to do next step and I am getting error like
How to fix this issue.Please anyone help me to get out of this issue. Thanks in advance
In the dev environment, you will always see the default exception page which is meant to ease debugging issues. If you want to see how a certain error page looks like in the prod environment (because you maybe created a custom template for it), you need to access a special URL that is only available for this purpose in the dev enviromnent (see https://symfony.com/doc/current/controller/error_pages.html#testing-error-pages-during-development). In your case, this URL is http://127.0.0.1:8000/_error/404
So this is the annoying kind of problem where something works perfectly on your local project, but everything breaks once deployed in production.
In this case, i can access all the pages generated by a regular codeigniter controller (situated in application/controllers). However, once i try accessing a HMVC module, i just get a codeigniter 404 error.
Situation still ok for regular controllers:
So for instance, if i have a regular controller C1 situated in application/controllers/C1.php, which contains the function page(), i can access www.mysite.com/C1/page without an issue.
Problem for accessing HMVC controllers:
However, if i want to access the controller C2 situated in application/modules/C2/controllers/C2.php, through the url www.mysite.com/C2/page, i'll get a 404 error.
And problem accessing regular controller through ajax:
A second issue appears when performing an ajax call, using a path which references a regular CI controller. The path used in the ajax call doesn't seem to be recognized, and i receive a 500 error. However, when calling the same path directly in the URL bar, the correct function seems to be executed. I had solved a similar issue before by applying the solution found in Codeigniter base_url() not working properly for ajax. However, i have not yet identified if this is the same issue.
It feels like a loader issue, but i'm no expert!
Even if it was a loader issue, why would it work on local and not on production?
Have you ever encountered something like this? Do you have an idea on how to tackle this issue?
**Edit 3: ** I removed the 2 previous edits because they are now irrelevant.
After activating the debug mode, and adding some logs, i finally found what i think to be the answer.
Long story short, my local codeigniter version runs on windows, and for some reason, when trying to reach a controller, the case is ignored. So File.php and file.php are considered the same.
My production server however runs linux, so it doesn't consider that 2 different file names refer to the same file. So i ask for file.php, and the server answer "there's no such file", because the file i actually want is File.php.
I need to turn in. I'll propose a proper answer tomorrow after running some more checks.
Thanks,
Loïc.
So the issue was not related to regular controllers versus HMVC controllers. Basically what happens is that my local dev environment is Windows, and for some reason, windows decides that the case doesn't matter when naming a file.
So file.php would be seen as the same name as File.php (notice that the first is lowercase and the second uppercase).
In my code, i was trying to get file.php (lowercase), while the actual file was named File.php and it worked, on windows.
However, in civilized operating systems File.php and file.php are considered 2 different names, and that's why suddenly things where not working in production, even though the code was the same. The controller files just could not be found.
I changed the names of my controller files (put them in lowercase) and things are working fine now.
Thanks everyone for your suggestions.
Loïc.
With HMVC routes need to be like
$route['something'] = "module/controller/function";
$route['something/(:any)'] = "module/controller/function/$1";
Make sure like that also when use controllers intead of welcome.php make sure controller filename like Welcome.php
When using routes if have not remove index.php from controller then url would be
With http://localhost/project/index.php/something
Without http://localhost/project/something
I have an issue making my cakephp project work on my shared hosting server.
I followed all the needed steps so it can work on local, and it's working. Once I upload on the server, in a specific domain name, only the homepage works, once I want to call another controller, i get the "404 - File or directory not found." error.
the project is hosted at : fme.tahrijouti.com. the domain redirects to the webroot folder in the cakephp structure.
My controller is : posts. I can make it work if I change the URL by specifying the controller & action, you can see it here.
I have checked and the rewrite module is on.
Can you please help me with that ?
Please have a look on CakePHP default routing. And don't forget to fix all your links.
Your links should have proper addresses. Just look on your Posts's link. These are like this http://fme.tahrijouti.com/index.php/posts/posts/view/2 but it should be http://fme.tahrijouti.com/index.php/posts/view/2. Remember after your host name there exist controller then a function of that controller then argument of that function like this: [host]/[controller]/[function]/[argument1]/[argument2]. Hope it helps. I think you can read cookbook another bit as most things are clear there from my experience.
As I don't have your codes of controller I cannot say more.
I have generated the Backend Application for the Symfony(1.4 and ORM Propel) project, in my Production env. But on calling the URL as http://www.mydomain.com/backend.php it is showing 404. Is there any config error or something like that..
Look inside your web folder and make sure that backend.php actually exists there, it might have been named something else [typo maybe]. Does mydomain.com work ?
Update
Disable/rename your .htaccess file temporarily and see if this fixes it. It looks like mod_rewrite is catching "backend.php" and passing it on as a module name.
The Problem was due to the Permission of the file i.e backend.php. I have changed the Owner/Group permission and the backend app started working. If any one had this kind of a problem, please check the file permissions, might help!
For rendering 404 page, the third parameter in your front controller must be false.
Like this:
ProjectConfiguration::getApplicationConfiguration('backend', 'dev', false);
my host account is something like:
~
~/public_html
~/public_html/system/application
to access my web, I need to put http://example.com/~userid in address bar
I install codeigniter in the ~/public_html directory, I can access http://example.com/~userid.
The Welcome page shows correctly, and the related user guide pages show correctly.
The problem is: if I create a new controller, and create new views, the web page just show "Error 404: Document Not Found". If I use http://example.com/~userid/welcome/index it has the same problem.
If I use base_url() function it shows http://example.com/~userid/
What should I do do fix this problem?
Thanks in advance!
Try http://example.com/~userid/index.php/welcome/index.
It looks like your URL rewriting is not set up or badly configured. This is the default way if URL rewriting is disabled.
EDIT See this page of the user guide, especially the section "Removing the index.php file" on how to set up URL rewriting.