autoload twilio in codeigniter - codeigniter

I have just downloaded twilio-php-master.zip and extracted the file to the libraries folder in codeigniter. I would like to know what files to set on $autoload['libraries'] = array() to use the REST API.
Thank you.

First extract the Twilio folder inside the twilio-php-master.zip into the same level as your applications folder in codeigniter,
Next set $config['composer_autoload'] = 'Twilio/autoload.php'; in your config.php
lastly add use Twilio\Rest\Client; in the controller where you are going to use Twilio
Hope this helps you...

Related

How can i download file in Codeingiter

I want to give download file option my webpage , but the file which i want to download is present on download link of another website , how can i directly download it from my webpage ,using CODEIGNITER
If you want download a file direct to your web site root folder use this code.
file_put_contents($_SERVER["DOCUMENT_ROOT"]."/your_folder_name/add_file_name.jpg..ect", "your_file_path_want_to_download");
hope it will help you.
You can download files using download helper in codeigniter. first you need to and $this->load->helper('download'); in your constructor or method. after that use following code for download.
force_download('/path/to/photo.jpg', NULL);
You can Use download helper in Codeigniter. simple load helper in your controller where you need like this
$this->load->helper('download');
here is ex
$data = 'Here is some text!';
$name = 'mytext.txt';
force_download($name, $data);

Codeigniter working directory inside another working directory

Hi I am working on codeigniter for a while now and have met with an issue.
I use "localhost/controller/function" which is how codeigniter works.
Where controller classes are in controller folder in application.
I have a new codeigniter setup in root folder names "big" with its own controller, view, models etc. How can I run files in "big" like I do for my the original application.
I tried "localhost/big/controller/function", which obviously didn't work.
Please help, I am completely new with codeigniter.
just go to index.php of your application (big)
change/add line:
$application_folder = "applications/big";

Codeigniter 2.1.3 HMVC templates from /public/themes

I'm using codeigniter 2.1.3 with wiredesignz HMVC, I was wondering how would I get templates from the public folder rather than the modules/module/views?
example structure
application/projects/projectname/ciappstructure
application/system/etc/
public/themes/themename/layout
public/themes/themename/pages
public/themes/themename/widgets
public/themes/themename/etc
I would love to use html files and have my template library sort out the tags and placement of widgets or modules, all modules and theme data being pulled from the DB
like:
$homepage = $this->load->view(FCPATH.'themes/$theme/pages/homepage.html', $data, TRUE);
Oh and another quick question, I'm new to HMVC, could I call modules::run('module/method', $params, $...); from a template library (/application/projects/project/libraries/template.php) ?
I've tried a few things but I can't seem to get anything working, any ideas are much appreciated! Thanks in advance
First, the $this->load->view() load views with .php extension not .html files, Second, this method only load the views on views/ folder.
Therefore, your need config first your modules folder in application/config.php file. Place this on the ends of file.
$config['modules_locations'] = array(
APPPATH . 'modules/' => '../modules/'
);
Next, create your first module with views as sub-folder, and create your view file with .php as extension.
- modules/
--- my_module/
------ views/
--------- my_view.php
Next, in your controller, load the view with the ubication of your module.
$this->load->view('my_module/my_view');
This must run, you can try and read more about the documentation.
Hope this help you!

When do we need to use base_url() function in codeIgniter?

I am working on a small project and all of my urls are written without base_url() function. So I was thinking what does those base_url() functions help with my urls. I know it will prefix the url based on configs file preferences. But simply I wanna ask
What is the advantage of using them ? and whats the disadvantage of not using them ?
The main advantage is that; when you want to migrate your project to online or in a different server; you won't need to edit your hard-coded links. The base_url() will make your inside links to get their base url dynamically.
echo base_url("blog/post/123");
will return
http://example.com/blog/post/123
in example.com and will return
http://jms.com/blog/post/123
in jms.com
base_url is needed when you create login/signup with email verification or forgot password functionality (Verifying by clicking the links like this http://yourdomain.com/auth/userid/code).
This is only one example, may have lot of uses.
the difference of base_url() and site_url() is that
both returns the url of your site but site_url() returns your site url, with attached index.php or on what you have configured $config['index_page'] = ''
in application/config/config.php
example www.yoursite.com/chicken/turkey
when using base_url(): Returns your site base URL, as specified in your config file.
you will get wwww.yoursite.com
when using site_url():
you will get www.yoursite.com/index.php
site_url() is usefull if you haven't change your .htaccess and you still access your controllers with index.php
base_url() is usefull when linking your css,js,or media stuffs. Granting that you still use index.php when accessing your controller/method
Its needed every-where, or at least we should use everywhere. Do you know, absolute url is far better then relative url? So, when you are using an absolute urls for all links on your site, instead of hard coded root domain name, you can use the "base_url()" function. Moreover, CI reactor is smart enough to detect the original base url, so you even don't need to enter it in config file.
I usually using the base_url() for the correct paths to the static files (css, js, img) files and the site_url() for the links to pages. site_url() will return with url_suffix witch could be set in application/config/config.php file
Advantage:-if you not use base_url() and you want to switch directory/server of your site , you should change the path all over the project.
if you use base_url(), just change it at onece in config.php ,effect on all site.

how to use third party script with codeigniter

i have got third polling scripts which has it's own admin panel, i want to integrate with my existing codeigniter site, what is the best way to iplement it ?
You should put the polling script into application/libraries and then initialize it using $this->load->library('yourclass'); Here is the documentation from the user guide.
Copy the files of the 3rd party script into a folder application/third_party
Refer to the script using require_once APPPATH . '/third_party/script_folder/script.main.class.php';

Resources