Thursday, November 29, 2012

IIS 7, CakePHP 2.2.3 and the Blog Tutorial

Hi everyone,

So, I (we, actually) decided to create a website. Because of the need to extend later on, we decided to use a framework. CakePHP looked very well to fit our needs. Installed it, configured it, and after some .htacces import to web.config files, it was functional! See http://dev.ov-ervaringen.nl/ for the default page of CakePHP. 

Happy as I was, I started to follow the blog tutorial. Created the desired pages and I came to the point where you actualy can see the magic happen: I browsed to http://dev.ov-ervaringen.nl/posts/index/ and... Nothing. OK, back to the tutorial, to make sure I didn't make a typo. Nothing. Everything seems fine. 

Now, I'm stuck. I don't have a clue where to search for the problem. 

Here are the files:

in app/Controller/PostsController.php
class PostsController extends AppController { 
public $helpers = array('Html', 'Form');
    
    public function index() {
$this->set('posts', $this->Post->find('all'));
}
}

in app/Model/Post.php 
class Post extends AppModel {
}

in app/View/Posts/index.ctp 
<!-- File: /app/View/Posts/index.ctp -->
<h1>Blog posts</h1>
<table>
<tr>
    <th>Id</th>
        <th>Title</th>
        <th>Created</th>
    </tr>
    
    <!-- Here is where we loop through our $posts array, printing out post info -->
    
    <?php foreach ($posts as $post): ?>
<tr>
    <td><?php echo $post['Post']['id']; ?>></td>
        <td>
        <?php echo $this->Html->link($post['Post']['title'], array('controller' => 'posts', 'action' => 'view', $post['post']['id'])); ?>
</td>
        <td><?php echo $post['Post']['created']; ?></td>
</tr>
    <?php endforeach; ?>
<?php unset($post); ?>
</table>

And, my web.config files:

in root:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="false" />
        <defaultDocument>
            <files>
                <clear />
                <add value="index.htm" />
                <add value="index.html" />
                <add value="index.php" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="Default.aspx" />
            </files>
        </defaultDocument>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^$" ignoreCase="false" />
                    <action type="Rewrite" url="app/webroot/" />
                </rule>
                <rule name="Imported Rule 2" stopProcessing="true">
                    <match url="(.*)" ignoreCase="false" />
                    <action type="Rewrite" url="app/webroot/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

in app/
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="false" />
        <rewrite>
            <rules>
<remove name="Imported Rule 1"/>
<remove name="Imported Rule 2"/>
                <rule name="app 1" stopProcessing="true">
                    <match url="^$" ignoreCase="false" />
                    <action type="Rewrite" url="webroot/" />
                </rule>
                <rule name="app 2" stopProcessing="true">
                    <match url="(.*)" ignoreCase="false" />
                    <action type="Rewrite" url="webroot/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

in app/webroot/
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
<remove name="app 1"/>
<remove name="app 2"/>
                <rule name="App Webroot 1" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

---

Is there anyone who is seeing the problem and has the solution to solve it?

Thanks in advance,

Jorick. 


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: