Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
[Extend Core Class] - Problem
  • Hi guys,
    I'm doing my first steps on the Framework FuelPHP. I installed and followed the following tutorials. I realized the standard agenda.
    I wish I do now extend a class Core FuelPHP, allow me to define my own methods. I followed the example with the class Lang. Lang in the child class, I created a test method.
    <?php
    class Lang extends Fuel\Core\Lang {
     
     public static function test(){
      return 'test';
     }
     
    }
    

    I changed the View object of my note, to test the extension class:
    <?php
    public function action_view($id = null)
     {
      echo Lang::test();
      
      $this->data['note'] = Model_Note::find_by_pk($id);
    
     }
    

    When I run my page I get the following error: ErrorException [ Error ]: Call to undefined method Fuel\Core\Lang::test()
    I do not understand my error can you help me?
    Thank you
  • You will have to define your class extension in app/classes/bootstrap.php, otherwise the autoloader doesn't know there's an extension. There's an example in the comments (of a View extension) so you can see what the syntax is.
  • Hello Harro,
    I have doing the same config in the FuelPHP documentation. Yesterday, like I don't understand the discard, I re-install FuelPHP framework. Now, It's ok. I can re define a Core class in an App class.
    Thanks for your help
    Djik

Howdy, Stranger!

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

In this Discussion