> For the complete documentation index, see [llms.txt](https://docs.minical.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.minical.io/build-an-extension/build-your-first-extension/library.md).

# Library

The library is a class with functions or methods that allows creating an instance of that class. For your extensions you can add a library under the libraries folder, the naming convention should be like GreetingEmail.php. here is an example of a library.

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

class GreetingEmail {

    public function __construct()
    {
        $this->ci =& get_instance();

        $this->ci->load->library('Email');
        $this->module_name = 'minical-extension-boilerplate';

    }   

    function send_greeting_email()
    {
        $company_id = $this->ci->session->userdata('current_company_id');
        $company = $this->ci->Company_model->get_company($company_id);

        $content =  'Dear [first name] I hope this email finds you well';
        $content1 = "<br/><br/>".'Thank you for your business'.",<br/><br/>"
            .$company['name']."
                <br/>".$company['email']. "<br/>".$company['phone']."<br/>";


        $config['mailtype'] = 'html';

        $this->ci->email->initialize($config);

        $email_data = array (
            'company_name' => $company['name'],
            'company_email' => $company['email'],
            'content' => $content,
            'content1' => $content1
        );

        $customer_email = $company['email'];

        $from_email = 'donotreply@minical.io';

        $email_from = $company['email'];

        $this->ci->email->from($email_from, $company['name']);
        $this->ci->email->to($customer_email);
        $this->ci->email->reply_to($email_data['company_email']);

        $this->ci->email->subject('Hello From miniCal');

        $this->ci->email->message($this->ci->load->view('../extensions/'.$this->module_name.'/views/gretting-mail-html', $email_data, true));

        $this->ci->email->send();
        $msg = l('minical-extension-boilerplate/Email successfully sent to ', true);
        return $msg.$customer_email;
    }

}
?>
```

**Loading of library**

You can load the library into controller, hooks, helper, or model, for loading your custom extension's library use the given syntax.&#x20;

$this->module\_name will have the extension name as value, or you can use the hardcode extension name at its place.

```php
//In controller 
$this->load->library('../extensions/'.$this->module_name.'/libraries/GreetingEmail');
$this->load->library('../extensions/minical-extension-boilerplate/libraries/GreetingEmail');

//In hooks and filter
$CI = &get_instance();
$CI->load->library('../extensions/minical-extension-boilerplate/libraries/GreetingEmail');
 
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.minical.io/build-an-extension/build-your-first-extension/library.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
