tags:

views:

86

answers:

3

Hi guys

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......I have no idea how to solve this problem...Any help would be greatly appreciated. Thanks

+2  A: 

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.

sipiatti
+1  A: 

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

Leo
I can see the page when I type http://localhost/myProject/. the page looks good to me(connect to database..etc). I use Ubuntu as my os... +1
Jerry
Is the page styled correctly? (eg: can you access the stylesheet URL - http://localhost/myProject/css/cake.generic.css if I am not mistaken, you can check the generated source for the actual URL)
NullUserException
A: 

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!

cdburgess