Welcome Guest, Not a member yet? Register   Sign In
Integrate third party library like unirest.io/php.html
#1

How to integrate in codeigniter 3

third party library like http://unirest.io/php.html

without using composer

thank you
Reply
#2

Figured this out through experimentation Smile

1) Download the Unirest repo.
2) Copy its src folder into your application/libraries, resulting in Unirest.php and the Unirest folder there.
3) Modify application/libraries/Unirest.php, adding a bogus class to make CI happy
Code:
<?php

require_once dirname(__FILE__) . '/Unirest/Exception.php';
require_once dirname(__FILE__) . '/Unirest/Method.php';
require_once dirname(__FILE__) . '/Unirest/Response.php';
require_once dirname(__FILE__) . '/Unirest/Request.php';
require_once dirname(__FILE__) . '/Unirest/Request/Body.php';

// bogus class to make CI happy
class Unirest {
}
4) You should now be able to use the conventional CI loader ... $this->load->library('unirest'); and then use the package per the Unirest docs Big Grin
Reply
#3

worked great, thank you,

i thought all this files must be inside third_party, i was confused.
So any libraries , external, shoud go inside app../libraries/
regards
Reply
#4

Unirest could have been bundled as a package too, in which case it would have gone inside application/third_party.

If you write a *library* that wraps an external "package", that would go inside application/libraries.
If you write a *package* that wraps an external "package", that would go inside application/third_party.
These are two different ways of achieving a similar effect.

If the external "package" includes classes, models and views, it would be better as a *package*.
Unirest was simple enough that I kept it as a library.
Reply
#5

i got it now, thank you for the explanation
Reply




Theme © iAndrew 2016 - Forum software by © MyBB