gpt4 book ai didi

php - Codeigniter 无法加载大型自定义库

转载 作者:行者123 更新时间:2023-11-29 07:03:03 25 4
gpt4 key购买 nike

An Error Was Encountered Unable to load the requested class:

Plugin_update_checker

我正在使用自定义库,它创建一个包含 740 行代码的动态 php 文件

Controller 功能:

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
}
}

最佳答案

库名称:/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';
}
}

Controller 代码:

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

试试这个!这段代码对我有用。

关于php - Codeigniter 无法加载大型自定义库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42682582/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com