CakePHP tutorial not seeing PostsController - cakephp

Im currently working on the cakephp tutorial, and have finished the first few steps. I've already added the post model controller(with the action) and view. For some reason though, when I go to www.mysite/posts/index I get a 404 error. I also noticed that the default www.mysite.com
says
Error: PhpController could not be found.
Any suggestions?
/PostsController.php/
<?php
class PostsController extends AppController {
public $helpers = array('Html', 'Form');
public function index() {
$this->set('posts', $this->Post->find('all'));
}
}
I also have a PagesController.php in the same directory. I posted it here http://jsfiddle.net/Z3jdu/
?>

i think u can find out by
Regarding pages controller never edit files in /cake/.. Override or extend them.
By default you shouldn't need an index.php, you should enable mod rewrite and allow cake php to read the urls correctly
Try checking your .htaccess and server config to ensure .htaccess can be read.
at the end i should mention this Check your root, app and webroot directories to see if they actually contain a .htaccess file.
Ensure your apache server configuration actually has the following (seeing as it's localhost, allow everything?):
Options FollowSymLinks
AllowOverride All
Order deny,allow
Allow from all
Ensure the following line is not commented with a hash tag (#)
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
Hopefully your app will work and you can start the blog tutorial to learn more

Related

CakePHP without mod_rewrite causes 404 errors

I'm pretty new to Cake, so I tryed to start with the blog tutorial.
I installed CakePHP 2.3.8 in webroot.
Configured SQL and deleted all 3 .htaccess-files, cause i have no mod_rewrite. In core.php I activated
Configure::write('App.baseUrl', env('SCRIPT_NAME'));
I created the Posts-Model, Controller and the index-View like the tutorial says.
The APP/View/Pages/home.ctp tells me, everything's allright.
But when i try to open /posts/index i get a 404. Why?
Without mod_rewrite the urls look like www.example.com/index.php/controllername/actionname/param, i.e. in your example you have to call /index.php/posts/index (or /index.php/posts/).

CakePHP and NearlyFreeSpeech.net

How do I set AllowOverride on NearlyFreeSpeech.net? I'm trying to follow the instructions at Within cakePHP, In my routes.php only the '/' (base path) works. Any other url is 404 page not found to resolve the problems described therein.
So far, I've had to do the following when moving out of a WAMP development environment:
Refer to controller names by their correct case
Change the name of the server in the configuration file
Add all the CakePHP-related files to the web group
The solution is as follows:
Copy the files over from your working environment (or do an export from your source control tool) into a new folder on NearlyFreeSpeech.net (NFS.net). Let's call the new folder "abc".
Import your database into NFS.net.
Configure database settings as necessary on the NFS.net version of the site.
Add the abc folder and everything in it to the web group.
Go into the .htaccess file in /home/public/abc and add "RewriteBase /abc" under "RewriteEngine on".
Add "RewriteBase /abc/app" to the .htaccess in /home/public/abc/app and add "RewriteBase /abc/app/webroot" to the one in /home/public/abc/app/webroot.

CakePHP Subcake Redirect

I have a problem with CakePHP (1.3) project, i need to create projects inside the same domain/hosting of other project, like this:
app
cake
plugins
templates
vendors
ADMINONE (Cake project files here)
ADMINTWO (another Cake project files here)
.htaccess
index.php
README
The problem is, when I put the CakePHP code inside ADMINONE or ADMINTWO to create the other cake projects, if I put the url http://domain.com/ADMINONE/, the URL redirects to http://domain.com or the cake read the /ADMINONE as a controller name.
How can I redirect this URL to the directory ignoring the primary directory cake's redirect?
Dont forget to change your index.php inside the webroot folder. In there you can set up the
APP_DIR and the ROOT if need be.

cakephp: configuring cakephp on shared host justhost

I tried to configure cakephp on justhost for my addon domain and i'm getting 404 not found error when I go to www.merryflowers.com/pages/home
Can someone please help me out?
The following are the changes I made in /webroot/index.php and /webroot/test.php
if (!defined('ROOT')) {
define('ROOT', DS.'home'.DS.'xxx'.DS.'public_html');
}
if (!defined('APP_DIR')) {
define('APP_DIR', 'merryflowers');
}
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('CAKE_CORE_INCLUDE_PATH', DS.'home'.DS.'xxx');
}
Do I need to make some changes to the .htaccess file? and .htaccess file from which folder?
under public_html/merryflowers.com/ i have:
views, plugins and webroot folder
thank you
It seems mod_rewrite isn't functioning properly, I can access the webrootdirectory (http://www.merryflowers.com/webroot/), which states that core.php can't be found. Before you look into possible mod_rewrite problems, ensure core.php is properly included.
I'm not sure you need to set all the paths in index.php, setting CAKE_CORE_INCLUDE_PATH might be enough.
You're full path isn't DS.'home'.DS.'xxx', but:
DS.'home'.DS.'xxx'.'public_html'.DS.'merryflowers.com'
You might want to set ROOT and APP_DIR to the default values, unless you need custom paths.

CakePHP 1.3.0 RC4 Installation

I have been using 1.2.6 and downloaded 1.3 to try it out. I am using wampserver with Apache 2.2.11. I have mod rewrite enabled. When I bake a new application using the cake 1.3 console, after I verify that the webroot/index.php of the application CAKE_CORE_INCLUDE_PATH is set to the Cake1.3 Installation folder. The result is a page thats missing CSS, missing a method. Typing in localhost/app/index.php will enable the program to find the app. Therefore I have to assume the rewrite module isnt functioning properly for v1.3. Is there something I have to add to the cake installation or app folder to make this function as it should?
No, Cake is set up properly from the start. The thing that always trips me up is that I forget to set my Apache virtual host's AllowOverride value to All. This allows the .htaccess file to be read.
Are there any error messages in your apache error logs?
Did you replace the previous application's directory with the new one? If not, you may need to add a tag with the appropriate AllowOverride permissions set inside your httpd.conf file, to allow mod rewrite to execute.
Can you load /css/style.css in your browser or does it give a 404?
This may sound like a silly question, but after you made your changes to AllowOverride in your Apache configuration, did you restart Apache?

Resources