我想把手放在cakephp上.所以我开始使用cakephp演示博客应用程序.我按照本教程的前几个步骤进行操作,当我尝试加载帖子控制器时,它说
Missing View Error: The view for PostsController::index() was not found. Error: Confirm you have created the file: T:\Project Folders\NetBeans\cakeBlog\app\View\Posts\index.ctp
我在stackoverflow,cakephp论坛甚至googlegroups中都搜索了很多这方面的内容,但是没有一个解决方案似乎对我有用.发布的大部分解决方案如下:
检查mod_rewrite是否已启用 - 是的我启用了它.
检查是否将index.ctp命名为index.ctp而不是index.cpt,Index.ctp或任何其他变体. - 是的我已将索引放置如下app/views/Posts/index.ctp(使用netbeans向导)
使用标签而不是php短标签 - 我使用传统的标签
发展环境
Web服务器 - WAMP我创建了一个名为cakeblog
并指向它的别名cakephp_folder/app/webroot/
cakeblog.conf
Alias /cakeblog/ "T:\Project Folders\NetBeans\cakeBlog\app\webroot/"Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny Allow from all
应用程序/根目录/ htaccess的
RewriteEngine On RewriteBase /cakeblog RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L]
我还加载了本地化和debugkit插件.我只是将已放置的文件夹放入app/plugin并在bootstrap.php中添加以下内容
bootstrap.php中
CakePlugin::load('DebugKit'); //Loads a single plugin named DebugKit CakePlugin::load('Localized');
core.php中
Configure::write('debug', 1);
我能够启动应用程序,我看到欢迎页面很好.我在startup.png中附上了它的快照
现在,让我粘贴代码,我只需从教程中复制粘贴:
应用程序/模型/ post.php中
应用程序/控制器/ PostsController.php
set('posts', $this->Post->find('all')); } public function view($id = null) { if (!$id) { throw new NotFoundException(__('Invalid post')); } $post = $this->Post->findById($id); if (!$post) { throw new NotFoundException(__('Invalid post')); } $this->set('post', $post); } } ?>
应用程序/视图/页/帖子/ index.ctp
Blog posts
Id | Title | Created |
---|---|---|
Html->link($post['Post']['title'], array('controller' => 'posts', 'action' => 'view', $post['Post']['id'])); ?> |
请检查附件output.png以获取我收到的输出的快照http://localhost/cakeblog/posts
: