Shapon Pal
Shapon Pal

Reputation: 1146

Codeigniter can't load big custom library

An Error Was Encountered Unable to load the requested class:

Plugin_update_checker

I am using custom library which create a dynamic php file with 740 line code

controller function:

public function create() {
    $userId=$this->session->userdata('userId');
    $userName=$this->session->userdata('userName');
    //Form_validation stuff
    $this->load->library('form_validation');

    $this->form_validation->set_rules('title', 'Title', 'required');
    $this->form_validation->set_rules('description', 'Description', 'required');
    $this->form_validation->set_rules('requires', 'Requires', 'required');
    $this->form_validation->set_rules('url', 'Homepage URL', 'required');

    if ($this->form_validation->run() == FALSE)
    {
       $this->index();
    }else {
        $data = array(
            'title' => $this->input->post('title'),
            'readme_text' => ($this->input->post('readme_text') == 'yes' ? 1 : 0),
            'description' => $this->input->post('description'),
            'requires' => $this->input->post('requires'),
            'url' => prep_url($this->input->post('url')),
            'user_id' => $userId
        );
        $insert_id = $this->model->insert_data($data);
        print ($insert_id);
        if ($insert_id) {
            $this->session->set_userdata('pluginId', $insert_id);
            $key = substr(number_format(time() * rand(),0,'',''),0,6).$insert_id;
           //$this->model->update_data(array('plugin_id' => $insert_id), array('secret_key' => $key,'php_file' => $WinnRepoPluginUpdater));
            $this->load->library('RepositoryHelper');



            // ------------------------Can't Load this Library ---------------------
            $this->load->library('Plugin_update_checker');
            // --------------------------------------------------------------------


            $repo= new RepositoryHelper();
            $php_code = new plugin_update_checker();
            $dir = 'api/'.$repo->sum($userId,1548).'-'.$repo->slug($userName).'/plugins/';
            $file_name = 'WinnRepo'.$repo->slug_space($data['title']).'PluginUpdater_'.$key;
            $WinnRepoPluginUpdater = $dir.'/'.$file_name.'.php';
            $repo->make_directory($dir);
            $url = base_url().'home/plugin_version_control/';
            //$code = $php_code->plugin_update_checker('WinnRepo_'.$key, $file_name, 'WinnRepoPluginUpdateChecker_2_1', $url, $key);
            $repo->make_file($WinnRepoPluginUpdater,'ccccccccccc');
            $this->model->update_data(array('plugin_id' => $insert_id), array('secret_key' => $key,'php_file' => $WinnRepoPluginUpdater));
            redirect('Plugins/view');
        }
    }
}

Here is custom Library:

class Plugin_update_checker
{

    public function plugin_update_checker($winnRepo, $className, $PluginUpdateChecker_2_1, $url, $licence_key)
    {
        echo '<?php ';
        ?>
       // Here 740 line which is auto generated a php file
       <?php
    }
} 

Upvotes: 0

Views: 42

Answers (1)

Parveen Chauhan
Parveen Chauhan

Reputation: 1496

Library name: /application/libraries/Plugin_update_checker.php

Code:

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Plugin_update_checker
{
    function __construct()
    {
        $this->ci =& get_instance();
    }

    function test(){
        return 'test';
    }
}

Controller Code:

public function index()
    {
        $this->load->library('Plugin_update_checker');
        echo $this->plugin_update_checker->test();
    }

Try this! This code work for me.

Upvotes: 2

Related Questions