Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Issue with security.php - get_class() expects 1 parameter
  • Hello there, I am following the tutorial on: http://net.tutsplus.com/tutorials/php/build-an-admin-panel-with-the-fuel-php-framework/ But I get an error after I put on the auth layer and try to go to: /blog/public/admin/posts:
    ErrorException [ Warning ]: get_class() expects parameter 1 to be object, null given COREPATH/classes/security.php @ line 204
    199            foreach ($value as $k => $v)
    200            {
    201                $value[$k] = static::htmlentities($v, $flags, $encoding, $double_encode);
    202            }
    203        }
    204        elseif ($value instanceof \Iterator or get_class($value) == 'stdClass')
    
    Backtrace COREPATH/classes/view.php @ line 204
    DOCROOT/index.php @ line 71

    What is causing this issue and how do I resolve it? Many thanks
  • I tried to pass NULL to Security::htmlentities(), but no error occurred. That tutorial is very old, and written for v1.1. It's got guaranteed to work on the current release. Which version of FuelPHP are you using, and can you post the code in the action to http://scrp.at so we can have a look?
  • When I do oil -v in the terminal it says: Fuel 1.3 The code I am trying to do is the same as the tutorial where it says: oil generate admin posts title:string slug:string summary:text body:text user_id:int This is when the issue occured. Should I replace the
    elseif ($value instanceof \Iterator or get_class($value) == 'stdClass')
    

    If I comment it out the app works fine. By commenting out I mean;
    elseif ($value instanceof \Iterator)// or get_class($value) == 'stdClass')
    
  • Just spend the last 15 minutes working through the tutorial on a brand new 1.4/develop installation, and I don't see any issues, everything works as advertised. 1.4 will be released this weekend, so if you're reluctant to work with a development version, just wait a few days.
  • Yeah its fine, I'm just learning FuelPHP and never knew it had an Admin feature so I wanted to have a go with it, its been good so far but little stumbling blocks are always going to happen. For example, in a seperate project I created a Model for Department - Company and Worker then wanted the admin generator to create -- but then it asked me if I wanted to overwrite the models I created, I'm not sure why it does that; there are times when I want to create the models in a certain way and let the admin only listen (read-only) the models and not over-write my models. But I guess I will get there.
  • 1.4 will have some improvements in that area. The generator is programmed to not blindly overwrite files, since you may have changed then (or even created them by hand). There is a commandline switch available to force the overwrite if you desire to do so.
  • Glad to hear it! I was seriousily concerned that Fuel was forcing me to work their way. I sometimes like writing up models myself in code, crafting up the schemas but I thought a bit disconcerting that when I try to do the admin generator I have to write the fields again. It'd be cool if I could say ignore create models or listen to model X or something. But I will check back when the new version is done.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion