Note that there are some explanatory texts on larger screens.

plurals
  1. POCakePHP, what url do I use for my app?
    text
    copied!<p>I have been having some trouble finding that link that shows my Model-View-Controller app in CakePHP (version 2.1.1), here are the details:</p> <p>I am using CakePHP (I'm using it for the first time, and I have been spending a fair amount of time getting it set up and trying to figure it all out.)</p> <p>I set it up on a Linux server, that caused me confusion above the mod rewrite - because the instructions for changing the .htaccess file don't work for the .htaccess file I have.</p> <p>On the server I am working on - the .htaccess file is under /root/tmp/, and that file has the following ONLY:</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; RewriteEngine on RewriteRule ^$ webroot/ [L] RewriteRule (.*) webroot/$1 [L] &lt;/IfModule&gt; </code></pre> <p>But the instructions seem to tell me to modify content in between the Directory opening and closing tags, but that doesn't exist here. So I uncommented that line in app/Config/core.php that says: Configure::write('App.baseUrl', env('SCRIPT_NAME')), since I didn't know how to change that in /root/tmp/.httaccess. And I deleted the files app/.httaccess, and app/webroot/.httaccess., and (tried the following both with and without /root/tmp/.httaccess file existing on the server).</p> <p>All of my CakePHP files are underneath: 192.168.1.109/CakePHP_211/cakephp_cakephp_0cad237, and I managed to get the page 192.168.1.109/CakePHP_211/cakephp_cakephp_0cad237 to look like:</p> <p><img src="https://i.stack.imgur.com/SFvjV.png" alt="192.168.1.109/CakePHP_211/cakephp_cakephp_0cad237"></p> <p>And that is due to having a:</p> <p>192.168.1.109/CakePHP_211/cakephp_cakephp_0cad237/app/Controller/CakePHP211Controller.php file with the following content:</p> <pre><code>&lt;?php class CakePHP211Controller extends AppController { public function cakephp_cakephp_0cad237() { } } ?&gt; </code></pre> <p>and a 192.168.1.109/CakePHP_211/cakephp_cakephp_0cad237/app/View/CakePHP211/cakephp_cakephp_0cad237.ctp file, with the following content:</p> <p>This is the view for CakePHP211Controller::cakephp_cakephp_0cad237()</p> <hr> <p>So that parts working, but when I try to make another Model-View-Controller app, I can't seem to get it to work: Here's what I'm doing:</p> <p>in 192.168.1.109/CakePHP_211/cakephp_cakephp_0cad237/app/Model/Post.php:</p> <pre><code>&lt;?php class Post extends AppModel { } </code></pre> <p>Then in 192.168.1.109/CakePHP_211/cakephp_cakephp_0cad237/app/Controller/PostsController.php:</p> <pre><code>&lt;?php class PostsController extends AppController { public $helpers = array('Html', 'Form'); public function index() { $this-&gt;set('posts', $this-&gt;Post-&gt;find('all')); } } </code></pre> <p>Then in 192.168.1.109/CakePHP_211/cakephp_cakephp_0cad237/app/View/Posts/index.ctp:</p> <pre><code>&lt;h1&gt;Blog posts&lt;/h1&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt;Id&lt;/th&gt; &lt;th&gt;Title&lt;/th&gt; &lt;th&gt;Created&lt;/th&gt; &lt;/tr&gt; &lt;!-- Here is where we loop through our $posts array, printing out post info --&gt; &lt;?php foreach ($posts as $post): ?&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo $post['Post']['id']; ?&gt;&lt;/td&gt; &lt;td&gt; &lt;?php echo $this-&gt;Html-&gt;link($post['Post']['title'], array('controller' =&gt; 'posts', 'action' =&gt; 'view', $post['Post']['id'])); ?&gt; &lt;/td&gt; &lt;td&gt;&lt;?php echo $post['Post']['created']; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php endforeach; ?&gt; &lt;/table&gt; </code></pre> <p>--</p> <p>So I'm trying to figure out the link that produces that index.ctp using the Post controller.</p> <p>192.168.1.109/CakePHP_211/cakephp_cakephp_0cad237/Post/index doesn't seem to work. 192.168.1.109/CakePHP_211/cakephp_cakephp_0cad237/index.php/Post/index doesn't seem to work. 192.168.1.109/192.168.1.109/CakePHP_211/cakephp_cakephp_0cad237/Posts/index doesn't seem to work. 192.168.1.109/192.168.1.109/CakePHP_211/cakephp_cakephp_0cad237/index.php/Posts/index doesn't seem to work.</p> <p>All of the above produce a "404 Not Found / nginx/1.0.6" error that looks like this:</p> <p><img src="https://i.stack.imgur.com/IS0xX.png" alt="404 Not Found Error"></p> <p>What do I do? What link to I use? Or is there some configurations I have to change? I have been struggling with this for hours, and trying to find the answers, but I haven't been able to. Help would be very much appreciated, thank you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload