Welcome Guest, Not a member yet? Register   Sign In
How use compser in Codeigniter
#1

Hi
I need use some composer packages in my project
Example packages :
https://packagist.org/packages/firebase/php-jwt
or
https://packagist.org/packages/kriswallsmith/buzz

I set autoloader config for composer in config.php and install these packages in vendor folder
But when i use it,there are many error

For example when i use php-jwt i have below error
Message: Class 'Firebase\JWT\JWT' not found

Guys i know that is existing jwt library for codeigniter
But i like i understand how do i use package in codeigniter
Reply
#2

How to Use Composer With Codeigniter

The easiest way to add composer into Codeigniter 3
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(09-06-2019, 12:15 PM)InsiteFX Wrote: How to Use Composer With Codeigniter

The easiest way to add composer into Codeigniter 3

Thank you my friend
For information,i can use pdfparser or some package in codeigniter
But i cannot use jwt or some packages
Do you can help me about jwt libary?
It is very good if we use library from composer packages because there are validate and tested
Thanks
Reply
#4

I believe that there is a post on the forums here some place,
I' ll see if I can find it in the morning.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(09-06-2019, 12:39 PM)omid_student Wrote:
(09-06-2019, 12:15 PM)InsiteFX Wrote: How to Use Composer With Codeigniter

The easiest way to add composer into Codeigniter 3

Thank you my friend
For information,i can use pdfparser or some package in codeigniter
But i cannot use jwt or some packages
Do you can help me about jwt libary?
It is very good if we use library from composer packages because there are validate and tested
Thanks

Example Code
Reply
#6

(This post was last modified: 09-07-2019, 04:08 AM by InsiteFX.)

Here is a better example of using it.

Composer with CodeIgniter

I think the example here adding

PHP Code:
include_once './vendor/autoload.php'

in index.php

Anyway he is showing how he used Buzz.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

(09-07-2019, 04:07 AM)InsiteFX Wrote: Here is a better example of using it.

Composer with CodeIgniter

I think the example here adding

PHP Code:
include_once './vendor/autoload.php'

in index.php

Anyway he is showing how he used Buzz.

https://github.com/bcit-ci/CodeIgniter/b...g.php#L121


He should post some code. The code could be wrong or a bug.
Reply
#8

My composer config is OK
I have problem only in Buzz or Firebase
Reply
#9

(09-07-2019, 07:21 AM)omid_student Wrote: My composer config is OK
I have problem only in Buzz or Firebase

I need an example code like this:
PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');
use \
Firebase\JWT\JWT;

class 
Test extends CI_Controller {

    public function 
index()
    {
        
$key "example_key";
        
$token = array(
            
"iss" => "http://example.org",
            
"aud" => "http://example.com",
            
"iat" => 1356999524,
            
"nbf" => 1357000000
        
);

        
$jwt JWT::encode($token$key);
        
$decoded JWT::decode($jwt$key, array('HS256'));

        
print_r($jwt);
        
print_r($decoded);
    }

This code works without error.
Reply
#10

(09-07-2019, 07:47 AM)Paradinight Wrote:
(09-07-2019, 07:21 AM)omid_student Wrote: My composer config is OK
I have problem only in Buzz or Firebase

I need an example code like this:
PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');
use \
Firebase\JWT\JWT;

class 
Test extends CI_Controller {

 public function 
index()
 {
 
$key "example_key";
 
$token = array(
 
"iss" => "http://example.org",
 
"aud" => "http://example.com",
 
"iat" => 1356999524,
 
"nbf" => 1357000000
 
);

 
$jwt JWT::encode($token$key);
 
$decoded JWT::decode($jwt$key, array('HS256'));

 
print_r($jwt);
 
print_r($decoded);
 }

This code works without error.

When i use require_once 'vendor/firebase/php-jwt/Firebase/PHP-JWT/Authentication/JWT.php';
and remove use \Firebase\JWT\JWT;
That is working good
Why?
I used autoload already
Reply




Theme © iAndrew 2016 - Forum software by © MyBB