在kohana 3.3.1中的请求中创建请求

时间:2015-12-30 12:11:25

标签: php kohana-3.3

我创建了一个与用户配置文件分开创建的消息控制器,因为多个位置可能存在消息,并且我正在尝试遵守DRY!规则。 这些是我的消息控制器

<?php defined('SYSPATH') or die('No direct script access.');

    class Controller_Messages extends Controller 
    {
        public function action_index()
        {
            URL::redirect();    
        }

        public function action_get_messages()
        {
            $messages = array(
                'This is test message one',
                'This is test message two',
                'This is test message three'
            );
        $this->response->body(View::factory('profile/messages')
            ->set('messages', $messages)
            );

        }
    }

我在配置文件控制器中请求控制器,如$messages = Request::factory('messages/get_messages')->execute()->response; 这些是我的完整个人资料控制器

<?php defined('SYSPATH') or die('No direct script access.');
    class Controller_Profile extends Controller_Application {
        public function action_index()
        {
            $content = View::factory('profile/public')
                ->set('username', 'Test User')
                ->bind('messages', $messages);
            $messages = Request::factory('Messages/get_messages')->execute()->response;
            $this->template->content = $content;
        }
    }

但是当我运行代码时我得到这些错误“ErrorException [注意]:数组到字符串转换”我在这里做错了什么伙伴请帮助我使用Kohana 3.3.3。 它用于与Kohana 3.0 - 3.2

一起使用

1 个答案:

答案 0 :(得分:0)

我已经解决了这个问题 一切都工作正常,只是因为我正在使用linux所以我不小心创建了2 profile.php ,如 Profile.php 和个人资料。
它导致了问题,因为在linux Profile.php profile.php 中由于大写而异。因此,当我浏览/配置文件时,服务器很困惑,并选择向我提供大写P的php页面。所以我要重命名文件,现在一切正常!

相关问题