Note that there are some explanatory texts on larger screens.

plurals
  1. POCakePHP, what url do I use for my app?
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COuhhh...start over. The random string of characters looks like you got it off of github and didn't extract it "properly". put everything (`app`, `lib`, `plugins`, `vendors`, `.htaccess`, `index.php`) in a folder (eg `my_app`, then add it to your `htdocs` or equivalent depending on setup. No way should you have that lengthy, random path. Access from `192.168.1.109/my_app`
      singulars
    2. COI am working in an office environment, with a local area network. The 192.168.1.109 is simply the path to the 'public_html' of our 109 server, where the PHP is set up, and the CakePHP_211 was a folder I created to install it all under. I downloaded CakePHP on windows, extracted it there into it's own folder, and then uploaded that to our 109 server. I'm not sure where the htdocs file is - I only found .htaccess and an svn folder under /root/tmp, and no other files. And I don't know what to do in the .htaccess folder, because it's very limited, with only that<IfModule mod_rewrite.c> content
      singulars
    3. CO/htdocs will reside within the webserver directory. some webservers call it /www, etc. but nonetheless, your .htaccess should be located under the corresponding project folder. for instance, mine is located in /apache/htdocs/bp-edi/.htaccess. This is my webroot for that project. hope that helps. And, yes, like @Ross said, sometimes it's best to start over.
      singulars
 

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