0

In order to learn how composer works

I created composer.json to download codeigniter with all dependencies

{
    "require": {
        "rogeriopradoj/codeigniter": "2.1.4"
    }
}

then created vendor directory using composer

After loading all these I want to just use form helpers that comes with codeigniter and I want to all this using composer(to know how composer works).

I created index.php having the following code and also have included require 'vendor/autoload.php';

<?php
// file name : index.php
require 'vendor/autoload.php';


class A extends CI_Controller
{   
    public function home()
    {
        $this->load->helper('form');
        echo form_open('email/send');

        $data = array(
                      'name'        => 'username',
                      'id'          => 'username',
                      'value'       => 'johndoe',
                      'maxlength'   => '100',
                      'size'        => '50',
                      'style'       => 'width:50%',
                    );

        echo form_input($data);
        echo form_close("</div>");      
    }

}

$a = new A;
$a->home();

?>

When I visit 127.0.0.1/index.php I get the following error

Notice: Undefined property: A::$load in C:\xampp\htdocs\M\index.php on line 14

Fatal error: Call to a member function helper() on a non-object in C:\xampp\htdocs\M\index.php on line 14

So its not working the way I wanted,anyone please explain what's wrong?

Update

After including form helpers but still getting this error,I have included vendor/autoload.php

Fatal error: Class 'CI_Controller' not found in C:\xampp\htdocs\M\index.php on line 7

Labeeb
  • 369
  • 2
  • 6
  • 18

1 Answers1

1

You've not set $load. It's like your doing something like null -> helper (); which explains the "call on a non object" error.

Edit : For your Class not found error, you could give a look at this :

Codeigniter Command line error - PHP Fatal error: Class 'CI_Controller' not found

Community
  • 1
  • 1
Clément Malet
  • 5,062
  • 3
  • 29
  • 48
  • Now I added $this->load->helper(); but still it does not work, "CI_Controller not found" – Labeeb Aug 23 '13 at 15:00
  • Did you include the file containing the CI_Controller class ? Maybe it is in the `vendor/autoload.php` file ? Add the new error to your main post as an edit please. – Clément Malet Aug 23 '13 at 15:02
  • I have added vendor/autoload.php, considering that it would take care of CI_Controller class – Labeeb Aug 23 '13 at 15:04
  • Edited my answer to add a link to a similar question on SO. Check it out, there are chances that you've the same problem. – Clément Malet Aug 23 '13 at 15:12