jwt-auth icon indicating copy to clipboard operation
jwt-auth copied to clipboard

Need support for PHP 8.0

Open poovarasudev opened this issue 3 years ago • 29 comments

Subject of the issue

Describe your issue here.

Your environment

Q A
Bug? yes
New Feature? yes
Framework Laravel
Framework version 8.x.y
Package version 4.x.y
PHP version 8.x.y

Kindly give support for PHP 8.x

poovarasudev avatar Jul 13 '21 14:07 poovarasudev

I work using PHP 8 latest version (the version of this comment is 8.0._1) and works fine and well.

Anyway, you didn't describe your issue too.

Messhias avatar Jul 14 '21 11:07 Messhias

@Messhias : Thanks for your time & reply. Kindly have a look on the below screenshot. Kindly help me to fix this issue.

Screenshot 2021-07-14 at 5 02 43 PM

poovarasudev avatar Jul 14 '21 11:07 poovarasudev

The problem's not this package, it's your laravel framework version, past your composer.json file.

Messhias avatar Jul 14 '21 11:07 Messhias

@Messhias FYI

composer.json file:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=8.0",
        "laravel/framework": "8.5",
        "tymon/jwt-auth": "1.0.2",
        "doctrine/dbal": "3.1.0",
        "league/flysystem-aws-s3-v3": "~1.0",
        "aws/aws-sdk-php": "3.183.9",
        "yajra/laravel-datatables-oracle": "9.18.0",
        "aws/aws-sdk-php-laravel": "3.6.0",
        "guzzlehttp/guzzle": "7.3.0",
        "dusterio/laravel-aws-worker": "^0.1.9",
        "maatwebsite/excel": "3.1.30",
        "maxbanton/cwh": "2.0.2",
        "wisembly/elephant.io": "3.3.1",
        "mjaschen/phpgeo": "3.2.1",
        "predis/predis": "1.1.7",
        "laravelcollective/html": "6.2.1",
        "tijsverkoyen/css-to-inline-styles": "2.2.3",
        "laravel/tinker": "2.6.1",
        "laravel/ui": "3.0",
        "yajra/laravel-datatables-html": "4.37.0",
        "yajra/laravel-datatables-buttons": "4.13.0",
        "barryvdh/laravel-dompdf": "^0.9.0"
    },
    "require-dev": {
        "facade/ignition": "2.9",
        "fakerphp/faker": "1.14.1",
        "mockery/mockery": "1.4.3",
        "nunomaduro/collision": "5.4",
        "phpunit/phpunit": "9.5.4"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        },
        "psr-0": {
            "Packages": "app/"
        },
        "files": [
            "app/Http/helpers.php",
            "app/Http/config-helpers.php",
            "app/Http/blade-helpers.php",
            "app/Http/constants.php",
            "tests/utilities/functions.php"
        ]
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ],
        "psr-4": {
            "Test\\": "tests/"
        }
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

poovarasudev avatar Jul 14 '21 12:07 poovarasudev

Hmmm, your composer it's quite larger than mine, but I'll post my composer require section for your reference because at least the commons packages seem different from mine.

Here:

"php": "^8.0",
        "ext-json": "*",
        "aws/aws-sdk-php-laravel": "~3.0",
        "darkaonline/l5-swagger": "^8.0",
        "facade/ignition": "^2.3.6",
        "fideloper/proxy": "^4.2",
        "fruitcake/laravel-cors": "^1.0",
        "goetas-webservices/xsd-reader": "^0.3.6",
        "guzzlehttp/guzzle": "^7.0.1",
        "illuminate/console": "^8.42",
        "intervention/image": "^2.5",
        "laravel/framework": "^8.0",
        "laravel/tinker": "^2.0",
        "league/flysystem-aws-s3-v3": "^1.0",
        "maatwebsite/excel": "^3.1",
        "monarobase/country-list": "^3.2",
        "owen-it/laravel-auditing": "^12.0",
        "predis/predis": "^1.1",
        "pusher/pusher-php-server": "^6.1",
        "s-ichikawa/laravel-sendgrid-driver": "^3.0",
        "thedoctor0/laravel-mailjet-driver": "^1.0",
        "twilio/sdk": "^6.24",
        "tymon/jwt-auth": "^1.0",
        "vlucas/phpdotenv": "^5.2",
        "zircote/swagger-php": "^3.1",
        "ext-pdo": "*"
        ```

Messhias avatar Jul 14 '21 12:07 Messhias

Work fine on PHP 8.0

decodedmrq avatar Jul 16 '21 17:07 decodedmrq

with composer param --ignore-platform-reqs , it's OK.

cjango avatar Jul 20 '21 06:07 cjango

The package doesn't support PHP 8.0

tymon/jwt-auth[1.0.0-rc.5, ..., 1.0.2] require php ^5.5.9|^7.0 -> your php version (8.0.5) does not satisfy that requirement.

smartens80 avatar Jul 23 '21 01:07 smartens80

The package doesn't support PHP 8.0

tymon/jwt-auth[1.0.0-rc.5, ..., 1.0.2] require php ^5.5.9|^7.0 -> your php version (8.0.5) does not satisfy that requirement.

As @cjango told you, try to use --ignore-platform-reqs.

And for me works fine without --ignore-platform-reqs, might be there's another library you're using that's blocking your composer package.

I'll show my composer.json as an example for you to take as reference:

        "php": "^8.0",
        "ext-json": "*",
        "aws/aws-sdk-php-laravel": "~3.0",
        "darkaonline/l5-swagger": "^8.0",
        "facade/ignition": "^2.3.6",
        "fideloper/proxy": "^4.2",
        "fruitcake/laravel-cors": "^1.0",
        "goetas-webservices/xsd-reader": "^0.3.6",
        "guzzlehttp/guzzle": "^7.0.1",
        "illuminate/console": "^8.42",
        "intervention/image": "^2.5",
        "laravel/framework": "^8.0",
        "laravel/tinker": "^2.0",
        "league/flysystem-aws-s3-v3": "^1.0",
        "maatwebsite/excel": "^3.1",
        "monarobase/country-list": "^3.2",
        "owen-it/laravel-auditing": "^12.0",
        "predis/predis": "^1.1",
        "pusher/pusher-php-server": "^6.1",
        "s-ichikawa/laravel-sendgrid-driver": "^3.0",
        "thedoctor0/laravel-mailjet-driver": "^1.0",
        "twilio/sdk": "^6.24",
        "tymon/jwt-auth": "^1.0",
        "vlucas/phpdotenv": "^5.2",
        "zircote/swagger-php": "^3.1",
        "ext-pdo": "*"

Messhias avatar Jul 23 '21 09:07 Messhias

The following command worked to me: composer require tymon/jwt-auth dev-develop

Curicows avatar Aug 04 '21 14:08 Curicows

The following command worked to me: composer require tymon/jwt-auth dev-develop

Bout time someone worked that out lol

smartens80 avatar Aug 04 '21 15:08 smartens80

i just put it line in composer.json in the section require "tymon/jwt-auth": "^1.0" and after composer update, i worked well

vojdel avatar Aug 09 '21 14:08 vojdel

The package seems to update to dev-develop now by default.

Before:

"name": "tymon/jwt-auth",
"version": "1.0.2",

After running composer update with unchanged configuration "tymon/jwt-auth": "^1.0.0":

"name": "tymon/jwt-auth",
"version": "dev-develop",

mathiaswillburger avatar Aug 09 '21 19:08 mathiaswillburger

Seems like this lib should upgrade because tymon/jwt-auth dev-develop requires lcobucci/jwt <3.4

lcobucci/jwt[3.3.0, ..., 3.3.3] require php ^5.6 || ^7.0 -> your php version (8.0.11) does not satisfy that requirement.

williamdes avatar Oct 11 '21 14:10 williamdes

Pssst, PHP 8.1 is out :-D

sergej-kurakin avatar Nov 29 '21 10:11 sergej-kurakin

Pssst, PHP 8.1 is out :-D

https://github.com/PHP-Open-Source-Saver/jwt-auth/discussions/76

Here we're keeping the branch going forward.

Messhias avatar Nov 29 '21 12:11 Messhias

tymon/jwt-auth in php 8.1 need lcobucci/jwt < 3.4, but all versions lower than 3.4 need php ^7.0 only

image

image

yurih567 avatar Dec 09 '21 18:12 yurih567

tymon/jwt-auth in php 8.1 need lcobucci/jwt < 3.4, but all versions lower than 3.4 need php ^7.0 only

FTR, as already pointed out, this is fixed in the fork at https://github.com/PHP-Open-Source-Saver/jwt-auth which supports 7.4,8+ and uses lcobucci/jwt 4

mfn avatar Dec 09 '21 19:12 mfn

PHP Deprecated:  Return type of Lcobucci\JWT\Claim\Basic::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/www/crm/vendor/lcobucci/jwt/src/Claim/Basic.php

Not support php 8.1

jinrenjie avatar Dec 29 '21 08:12 jinrenjie

I am getting this error after updating my php version

<br/><b>Deprecated</b>: ReturntypeofTymon\JWTAuth\Claims\Claim: : jsonSerialize()shouldeitherbecompatiblewithJsonSerializable: : jsonSerialize(): mixed, orthe#[ \ReturnTypeWillChange ]attributeshouldbeusedtotemporarilysuppressthenoticein<b>/Users/saifurrahman/www/lumen-jwt-auth/vendor/tymon/jwt-auth/src/Claims/Claim.php</b>online<b>147</b><br/>{ "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sdW1lbi1qd3QtYXV0aC50ZXN0XC9hcGlcL2F1dGhcL2xvZ2luIiwiaWF0IjoxNjQwOTIxNzQ1LCJleHAiOjE2NDA5MjUzNDUsIm5iZiI6MTY0MDkyMTc0NSwianRpIjoiOXlWc1NQUm9wUG1lVG5mWiIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.p3Blmp1_sJtozADqFPBjavGtf_NPmpJUBjhgez_ENYE", "token_type": "bearer", "expires_in": 3600 }

Php version:

PHP 8.1.0 (cli) (built: Nov 28 2021 01:31:19) (NTS)

Composer.json

{
    "name": "laravel/lumen",
    "description": "The Laravel Lumen Framework.",
    "keywords": ["framework", "laravel", "lumen"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": "^7.3|^8.0",
        "flipbox/lumen-generator": "^8.2",
        "laravel/lumen-framework": "^8.3.1",
        "tymon/jwt-auth": "dev-develop"
    },
    "require-dev": {
        "fakerphp/faker": "^1.9.1",
        "mockery/mockery": "^1.3.1",
        "phpunit/phpunit": "^9.5.10"
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ]
    }
}

Please help someone.

saifur-rahman-hasan avatar Dec 31 '21 17:12 saifur-rahman-hasan

@saifur-rahman-hasan not sure it support 8.1 yet. I was having exact error as yours while trying to run Laravel test on php 8.1. You should use 8.0

AbdullahiAbdulkabir avatar Dec 31 '21 17:12 AbdullahiAbdulkabir

Version 1.0.2 does not support PHP 8, you can just see it here: https://packagist.org/packages/tymon/jwt-auth , the same with version 2.0.0.

vedmant avatar Jan 07 '22 05:01 vedmant

image

It's also a problem with 8.1

noecs avatar Jan 09 '22 07:01 noecs

Couple of things for people commenting here after my comment https://github.com/tymondesigns/jwt-auth/issues/2141#issuecomment-990154168

  • it's not an error, it's a DEPRECATION WARNING It's best practice to disable them in production, btw
  • that said, https://github.com/tymondesigns/jwt-auth/issues/2141#issuecomment-990154168 leads to a forked version of this library which supports 8 and later versions

✌🏼

mfn avatar Jan 09 '22 10:01 mfn

@mfn If this package is deprecated then it should be something on the front page about it. But current'y this one has 10k stars and PHP-Open-Source-Saver has just 87. Current package has no any release that supports PHP 8. I'd not pull development version for production app, either I'd not use some unknown fork with little contribution for production app.

vedmant avatar Jan 09 '22 13:01 vedmant

It's pretty clear the repository has been abandoned. Use the recommended fork or fork and do your own thing.

smartens80 avatar Jan 09 '22 13:01 smartens80

@vedmant

If this package is deprecated then it should be something on the front page about it

I agree, but that maintainer hasn't been active in in a year, so draw your own conclusion.

mfn avatar Jan 09 '22 13:01 mfn

@vedmant

If this package is deprecated then it should be something on the front page about it

I agree, but that maintainer hasn't been active in in a year, so draw your own conclusion.

👍

smartens80 avatar Jan 09 '22 15:01 smartens80

@mfn If this package is deprecated then it should be something on the front page about it. But current'y this one has 10k stars and PHP-Open-Source-Saver has just 87. Current package has no any release that supports PHP 8. I'd not pull development version for production app, either I'd not use some unknown fork with little contribution for production app.

This package has been abandoned, I tried to enter in contact by email with @tymondesigns, and I tried also to contribute, as you can the package is going to be 2 years without updates, without issues answering.

The fact the repository has 10k stars or 0 doesn't mean anything, as @mfn told you, just look at the repository update history and draw your own conclusions.

Messhias avatar Jan 10 '22 14:01 Messhias