Apache not loading view inside another view of codeigniter - php

I wrote a codeigniter app and deployed in apache. after checking in browser, single view controllers are loading very fine. but i made all css headers and some session management codes into one php file named header.php. So i had to call this php view in every other views. But, browser shows
Unable to load the requested file: Header/header.php
i wrote this line in my all views to call header view
<?php $this->load->view('Header/header.php'); ?>.
Any help would be appreciated.

I finally found solution. When running CI app in localhost, it is not that case sensitive. actually i tested it in windows. Windows is not much case sensitive in directory names. But, when CI app deployed in apache ubuntu it becomes more case sensitive. Inside every module, CI models, controllers, views folder names should be in lowercase. In my case, views folder of Header module was Uppercase.

Related

PHPStorm and CodeIgniter routing issue

I started studying CodeIgniter Web Framework and I am trying to work with PHPStorm 8.0.3 on Kubuntu 14.04. When I unzip CodeIgniter downloaded archive to root Apache folder /var/www/html and go to
localhost/index.php
then it works okay and I see "Welcome to CodeIgniter!" page. Also I
can use
localhost/index.php/welcome/index
and see the same page as it should be.
When I created a new PHP project in PHPStorm and try
localhost:63342/codeignitor/index.php/
then I see welcome page, but if I use
localhost:63342/codeignitor/index.php/welcome/index
then I get 404 page. Also all my own controllers are not available and
cause 404.
I can call my own controller only if I make it default
$route['default_controller'] = 'mycontroller';
I think that this problem occurs because the URL contains name of my project /codeignitor/, but I'm not sure about it. So I need your advice how to set CodeIgniter environment in PHPStorm correctly to solve this problem. Thank you!
Codeigniter uses the URL to determine routing, therefore /codeigniter/index.php/welcome/index and /index.php/welcome/index are not equal paths. I would recommend using one or the other, and adjusting your /index.php and /config/routes.php to accommodate for your desired path.
References:
Codeigniter Subfolder
https://www.codeigniter.com/user_guide/general/urls.html
https://www.codeigniter.com/user_guide/general/routing.html
https://www.codeigniter.com/user_guide/general/environments.html

Yii 1.1.16 : components folder is not accessible all over the application in Ubuntu

The error I'm getting is:
include(widgetHomeMenu.php): failed to open stream: No such file or directory
same for all other widget views I'm rendering on other pages.
The file is in my components directory. I guess the directory is not accessible because the file exists there. Plus I've given permission to all the files in /var/www.
Also in my config.php file, there is:
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
),
So, I guess the config is loading components as well.
Not sure where is the problem exactly. No problems with case sensitivity, its correct and the filename is correct as well. The application is working flawlessly on several Windows PC using xampp.
Will be thankful for any help.
I found the problem. It was ultimately related to case sensitivity even though I mentioned above that there was no such problem.
I was loading the widget like this:
<?php $this->widget('widgetDashboardMenu');?>
where I thought that widgetDashboardMenu was the name of the view that was about to render (my bad). This was actually the controller inside components named WidgetDashboardMenu which then loaded widgetDashboardMenu.
So, changing w to W solved the problem for me.
<?php $this->widget('WidgetDashboardMenu');?>

Cakephp Requires Controller

Can anyone help me,
i developed my application with Cakephp 2.1, and it works fine on my development server running Centos 5.7. My challenge came when i transfer my application to the lice server to be accessed by on LAN. It states that a missing controller which is not available in my whole application, for example, i named my folder which contains my application and uploaded to the correct folder in Centos, e.g /var/www/html/students and every time i need to access the application states that students controller is missing. I tried to rename my folder to 'mysite' and the errors still remain with mysite controller is missing.
So everytime i changed the name of the folder it states a missing controller for that named folder. I tried to figure out in core.php but cant find the solution.
To change the base directory to say /mysite you will have to modify your 3 .htaccess of cakephp i.e one in installlation folder , second inside the app folder,third inside the webroot folder
try adding:-
RewriteBase /mysite/
Hope this helps!

How to load view from application/myfolder/ path in CodeIgniter

I was loading view in CodeIgniter as
$this->load->view('../../myfolder/footer');
It was working fine on windows machine. I have uploaded app to linux machine and start getting error
Unable to load the requested file: ../../myfolder/header.php
myfolder is in CI application folder.
How can i load view from application/myfolder
Please help me and thank you in advance.
Why you need tho load views in application/myfolder?? Code Igniter expects that views are located in application/views or application/views/myfolder. Put your files in application/views and then you can load it using:
this->load->view('footer');
or
this->load->view('myfolder/footer');
If it worked on Windows but no longer works on Unix, it could be because the filepaths are case sensitive in Unix.
Check the file structure and file names to make sure they match the CodeIgniter requests exactly.
E.g.:
$this->load->view('../../myfolder/footer');
Will fail trying to load:
../../MyFolder/footer
../../myfolder/Footer
../../MyFolder/Footer
etc
$this->load->view(base_url().'myfolder/footer');
That should work but I have no idea why you're trying to work outside the views folder to begin with. Just structure your views folder like below. Load the header, footer and anything else that's static from a template page.
Views
--pages
--admin
--templates
--etc.

How do I get CakePHP configured so it shows up correctly in my browser?

I am a cakephp newbie and I had trouble to view the files under the view folder through browser.
I used cakephp console to bake model, controller and views. (ex: Invoices_controller.php for controller, invoice.php for model and a invoices folders under views folder). According to the tutorial I read, I can access the invoice view by typing http://localhost/myProject/invoices
(there is no index.php inside the invoices folder..but the tutorial shows it still can display a page. no idea how they did it)
The path for my invoices is myProject/views/invoices and there add.ctp, index.ctp, edit.ctp files inside the invoices folder.
The browser showed the file is not found when I typed http://localhost/myProject/invoices
You have some lack in your knowledge about how the webserver handling a request when cakephp is installed. Assume that we use apache.
In cake's folder structure you can see .htaccess files in the root, app and webroot directories what have url rewrite rules in them. At the end a normal request to a cakephp site will be transformed to a http://site.url.root/app/webroot/index.php?url=original.url
In nutshell to understand it in your point of view:
That index.php call the required php files and at least a cakephp app object is built up in the memory with the required models and methods. Then the app object let say start and calls its methods (model, controller and view methods) and at the end it gives back a result to apache what serves it to you.
Therefore the original url path is a "non existent" virtual url.
If you enter http://localhost/myProject/ do you get a cake intro page? If so does it highlight any problems?
It sounds to me as if you do not have Apache set up properly. I don't know what OS you're using, but it might be worth checking this link, written for Ubuntu, to make sure all is well: http://leoponton.blogspot.com/2010/05/getting-cakephp-up-and-running-on.html
I fixed the same problem.
if you are using windows 7 os, wamp server, cakephp 2.2.3. then
goto apache -> http.conf -> open -> search for mod_rewrite -> uncomment the line LoadModule rewrite_module modules/mod_rewrite.so
Now restart your server, now it should work fine.
Jerry, I think the issue is this. You have put the CakePHP folder in the root of localhost. I would propose that you create a virtual host pointing the myProject so the url becomes:
http://myProject/accounting
This may solve your problem. Be sure rewrite module is on. Also, when you point the virtual host to myProject, it should be the APP folder of the cakephp. If you want to run multiple projects off the same core, you can set them up like so:
/var/www/cake
/var/www/html/myProject
/var/www/html/myProject2
The /var/www/cake directory is where you drop the cake core. Under this directory you will have cake, app, plugins, vendors, etc. the myProject(2) directories will be the contents of the app directory.
Now, to get this to work, you need to go to /var/www/html/myProject/webroot/index.php and edit it to point to the cake directory in /var/www/cake. This will then load the core when rewrite points to index.php in webroot. You should be good to go!

Categories