Welcome Guest, Not a member yet? Register   Sign In
Make custom driver
#1

Hello guys
I try to make driver with below sample code
https://stackoverflow.com/questions/2353...odeigniter
but it get error "Invalid driver requested: Testdriver_first_driver"
Why?
Reply
#2

I think the code in SO is for CI 2.
That might nor work in CI3 without modifications.

Ralf
On the package it said needs Windows 7 or better. So I installed Linux.
Reply
#3

(09-20-2017, 08:01 AM)rtenny Wrote: I think the code in SO is for CI 2.
That might nor work in CI3 without modifications.

Ralf

Do you have solution?
Reply
#4

Very sorry, dont even know what a driver would be for.
I cannot help you with this at all.
On the package it said needs Windows 7 or better. So I installed Linux.
Reply
#5

(09-21-2017, 04:23 AM)rtenny Wrote: Very sorry, dont even know what a driver would be for.
I cannot help you with this at all.
Is there exist looklike driver?
Reply
#6

(09-24-2017, 02:00 AM)omid_student Wrote:
(09-21-2017, 04:23 AM)rtenny Wrote: Very sorry, dont even know what a driver would be for.
I cannot help you with this at all.
Is there exist looklike driver?

Take a look to a file named /system/libraries/Session/Session_driver.php , it is a form to make drivers in CI 3.
Reply
#7

(09-26-2017, 05:00 AM)XMadMax Wrote:
(09-24-2017, 02:00 AM)omid_student Wrote:
(09-21-2017, 04:23 AM)rtenny Wrote: Very sorry, dont even know what a driver would be for.
I cannot help you with this at all.
Is there exist looklike driver?

Take a look to a file named /system/libraries/Session/Session_driver.php , it is a form to make drivers in CI 3.

Thanks
Do you suggest other way instead of driver?
I want to make driver or library for send message via SMS,Push,Email
Reply
#8

You can either make a helper function and put it under helper dir or make a useful class and put it under libraries. It is entirely
up to you and depends on how you implement it.

I will make a email class and maybe sms as extends of email then a push class whatever.

The advantage to place them under libraries or helpers dir is you can call them to any controllers / models.

Regards
Reply
#9

Here is an example of how I make a custom lib email, it is for your reference on how I do it
Code:
/**
@author : yourname
*/
// 1. google and copy the phpmailer class
// 2. put this class under application/libraries
// 3. and your custom class Myemail
// 4. Config email.php to your setting, assume use of gmail but you can use any of your email server
//    copy email.php to application/config  

class Myemail {
    protected $CI;
    function __construct(){
      $CI = &get_instance();
      $CI->config->load('email'); // specific config email file
      $CI->load->library('phpmailer'); // I use phpmailer as third party email program
    }    
    function sendEmail($email_from,$name_from,$subject,$message, $mailto, $name_mailto=NULL){
                  $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
                  $mail->IsSMTP(); // telling the class to use SMTP
           try {
                     
                      $mail->Host=$CI->config->item('smtp_host');
                     $mail->SMTPDebug  = 0;                     // enables SMTP debug      
                     $mail->AddAddress($mailto, $name_mailto);
                     $mail->SetFrom($email_from, $name_from);
                     $mail->AddReplyTo($email_from, $name_from);
                     $mail->Subject = $subject;
                     $mail->AltBody = 'Please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
                     $mail->MsgHTML($message);
                     $status=$mail->Send();
                     
                     //return boolean true as 1
                   
                    if(!$status){
                           throw new Exception($mail->ErrorInfo);
                    }else{
                             if($mail->ErrorInfo!==''){
                                 return FALSE;
                             }
                             else{
                                 return TRUE;
                             }

                    }
               } catch (phpmailerException $e) {
                 
                    return $e->errorMessage();
               } catch (Exception $e) {

                 
                     return $e->getMessage();
           }
   }// end function email
}
/* below is email.php as sample config file and put this under application/config*/
/*
smtp_host    No Default    None    SMTP Server Address.
smtp_user    No Default    None    SMTP Username.
smtp_pass    No Default    None    SMTP Password.
smtp_port    25    None    SMTP Port.
smtp_timeout    5    None    SMTP Timeout (in seconds).
wordwrap    TRUE    TRUE or FALSE (boolean)    Enable word-wrap.
*/
$config['protocol'] = 'smtp';
$config['mailpath'] =  ''; //'/usr/sbin/sendmail';
$config['smtp_host'] = ''; //smtp-relay.gmail.com';//

$config['smtp_user'] = 'youruser';
$config['smtp_pass']= 'password';
$config['smtp_port']= 587;
$config['smtp_timeout']=5;
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['email_default']='';
/* END email.php config file*/
Reply




Theme © iAndrew 2016 - Forum software by © MyBB