Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8639565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:02:38+00:00 2026-06-12T11:02:38+00:00

This could be a simple problem but is messing my head out. The thing

  • 0

This could be a simple problem but is messing my head out.

The thing is I’m doing a project with fuelPHP, RedBean and Twig. All seems to work fine and I’m progressing really well with this framework.

The problem I encounter which I’ve not find any solution yet is that Twig it’s not able to access {{object.property}} if I get the object from redbean. Which is totally strange because if I use my own MVC framework the exact same code (Twig+Redbean also) works.

For example

public function action_messages() {
    $room = \Uri::segment(3);
    $this->data['messages'] = \R::find('message', 'room = ? ORDER BY id', array($room));
    
    // This is working because it's converting each row to array
    /*foreach($this->data['messages'] as $id => $message)
        $this->data['messages'][$id] = $message->export();*/
    
    return \Response::forge(\View::forge('chat/messages.twig', $this->data));
}

The thing works as expected if I get the export as an array but not as an object.

{%for message in messages%}
     <b>{{message.user.id}}</b>{{message.datetime}}: {{message.text}}
{%endfor%}

I’m really lost with this. So I would appreciate any possible help.

Edit: (More info)

If I put

{%for message in messages%}
{{message}}<br/>
{%endfor%}

I get this output from the Var.

{"id":"23","text":"A test","room":"1","datetime":"2012-10-05 15:32:36","user_id":"1"}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:02:40+00:00Added an answer on June 12, 2026 at 11:02 am

    Finally I got it working.

    The problem was in the Twig config in the FuelPHP framework.

    The auto_encode parameter does the conversion of json to array in case of object properties. So you MUST set it to false (It’s true by default).

    Adjust your config to get something like this.

    // TWIG ( http://www.twig-project.org/documentation )
    // ------------------------------------------------------------------------
    'View_Twig' => array(
        'include' => APPPATH.'vendor'.DS.'Twig'.DS.'Autoloader.php',
        'auto_encode' => false, // Remember to set this to false
        'views_paths' => array(APPPATH.'views'),
        'delimiters' => array(
            'tag_block'     => array('left' => '{%', 'right' => '%}'),
            'tag_comment'   => array('left' => '{#', 'right' => '#}'),
            'tag_variable'  => array('left' => '{{', 'right' => '}}'),
        ),
        'environment' => array(
            'debug'                => false,
            'charset'              => 'utf-8',
            'base_template_class'  => 'Twig_Template',
            'cache'                => APPPATH.'cache'.DS.'twig'.DS,
            'auto_reload'          => true,
            'strict_variables'     => false,
            'autoescape'           => false,
            'optimizations'        => -1,
        ),
        'extensions' => array(
            'Twig_Fuel_Extension'
        ),
    ),
    

    And it will work like a charm 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this may seem like a simple problem but I couldn't find it in the
This is a really simple problem, but I couldn't find a solution anywhere. I'm
I am new on this stuff and this could be a simple question, but
This is a simple question,I guess, but I couldn't figure it out. How do
I have to complete a project but I have a simple problem I have
Morning all, I know that this sounds like a simple referencing problem from the
I think this is a very simple problem and I could be just going
This seems like an incredibly simple problem however it isn't working out as trivially
All this is probably a real simple one but I am missing something and
So this seems like it's a very simple problem to anyone at all conversant

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.