Welcome Guest, Not a member yet? Register   Sign In
load custom lib
#1

Hello ,
my name is gunnar i am new here.
i hope maybe someone is able to help me cause i am stuck and this forum and also google didnt show any solution.

i use CI 3, newest v.

if i insert any lib (here as exmp Someclass.php) in my application/libaries folder , just for testing.

PHP Code:
defined('BASEPATH') OR exit('No direct script access allowed');

class 
Someclass {

        protected $CI;

        // We'll use a constructor, as you can't directly call a function
        // from a property definition.
        public function __construct()
        {
            // Assign the CodeIgniter super-object
            $this->CI =& get_instance();
        }

        public function foo()
        {
            $this->CI->load->helper('url');
            redirect();
        }

        public function bar()
        {
            echo $this->CI->config->item('base_url');
        }
        public function some_method()
        {
            echo 'hallo test method';
        }


and call it at my controller:
PHP Code:
class Products extends CI_Controller {
  
    
function __construct() {
        parent::__construct();


      
        
// Load product model
        $this->load->model('product');
    }
  
    
public function index(){
        // Load Stripe library
        $this->load->library('someclass');


        $data = array();
        $data $this->input->get();
        // Get products from the database
      

        
// Pass products data to the list view
        $this->load->view('index',$data);
    

...
i get no CT Error but my apache log  give me 500 and -> PHP Fatal error:  Class 'CI_Someclass' not found in /var/www ... /system/core/Common.php on line 198
at this point
new $name();

i tried to manipulate the common.php without a solution.
maybe i oversaw something.
big thx if someone have an idea i am done Wink
Reply




Theme © iAndrew 2016 - Forum software by © MyBB