Welcome Guest, Not a member yet? Register   Sign In
How to load in custom library in ci4

(This post was last modified: 04-05-2020, 12:37 PM by 404NotFound.)

(11-01-2019, 02:52 AM)seunex Wrote: I was trying to load custom libraries in ci4 to try and implement smarty with ci4 as we do in ci3 has anyone here try and be succeeded.

If ci4 don't allow me to use smarty template engine I stuck with ci3.

I use firebase/php-jwt library with composer
composer require firebase/php-jwt
Note that when you use composer, your library is put in vendor folder

Then I just load it in my controller:

PHP Code:
use Firebase\JWT\JWT;
MyController extends Controller {
   public function index() {
      $key 'blablabla';
      $jwt = new JWT();
      $payload = array(
         'iss' => base_url(),
         'name' => 'Hello World'
      $token $jwt->encode($payload$key);
      echo $token;

It's working for me, I hope it helps others too.
It's better in my point of view


Messages In This Thread
How to load in custom library in ci4 - by seunex - 11-01-2019, 02:52 AM
RE: How to load in custom library in ci4 - by 404NotFound - 04-05-2020, 12:25 PM

Theme © iAndrew 2016 - Forum software by © MyBB