遇到错误无法加载请求的类:
Plugin_update_checker
我正在使用自定义库,它创建一个带有740行代码的动态php文件
控制器功能:
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');
}
}
}
这是自定义库:
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
}
}
答案 0 :(得分:2)
图书馆名称:/application/libraries/Plugin_update_checker.php
代码:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Plugin_update_checker
{
function __construct()
{
$this->ci =& get_instance();
}
function test(){
return 'test';
}
}
控制器代码:
public function index()
{
$this->load->library('Plugin_update_checker');
echo $this->plugin_update_checker->test();
}
试试这个!这段代码对我有用。