为什么我要在PHP中收到未定义的类型?

发布于 2025-02-03 16:51:29 字数 1511 浏览 1 评论 0原文

我正在使用 spomky labs的jwt framework库 v3.0 v3.0 for php for php创建 jwe tokens

我已经运行了作曲家需要Web-Token/JWT-Cryption在我的PHP项目中安装库。这是我的composer.json

{
    "require": {
        "web-token/jwt-encryption": "^3.0",
        "web-token/jwt-core": "^3.0"
    }
}

开始导入不同的名称空间时 - 例如,加密算法命名空间:

<?php

require_once realpath("vendor/autoload.php");

use Jose\Component\Encryption\Algorithm\KeyEncryption\A256KW;
use Jose\Component\Encryption\Algorithm\ContentEncryption\A256CBCHS512;

?>

VSCODE PHP Intellisense不会显示任何错误。

但是,当我开始使用这些名称空间时,IntelliSense开始显示

未定义的类型'插入名称空间'

示例:

“

这是我的文件夹结构:

XAMPP/
├─ htdocs/
│  ├─ encryption_project/
│  │  ├─ index.php
│  │  ├─ composer.lock
│  │  ├─ composer.json
│  │  ├─ vendor/
│  │  │  ├─ autoload.php
│  │  │  ├─ web-token/
│  │  │  │  ├─ jwt-encryption/
│  │  │  │  ├─ jwt-core/

我使用XAMPP(Apache Web服务器)来运行我的PHP代码并在Vscode中进行编辑。

我的操作系统是Macos Monterey。我的PHP版本是8.1.6

I'm using Spomky Labs' JWT Framework Library v3.0 for PHP to create JWE Tokens.

I've ran composer require web-token/jwt-encryption to install the library in my PHP project. Here's my composer.json

{
    "require": {
        "web-token/jwt-encryption": "^3.0",
        "web-token/jwt-core": "^3.0"
    }
}

When I start importing the different namespaces - for example the Encryption Algorithms namespace:

<?php

require_once realpath("vendor/autoload.php");

use Jose\Component\Encryption\Algorithm\KeyEncryption\A256KW;
use Jose\Component\Encryption\Algorithm\ContentEncryption\A256CBCHS512;

?>

VSCode PHP IntelliSense does not show any error.

But when I start using these namespaces, IntelliSense starts showing an error of

Undefined type 'insert namespace here'

Example:

IntelliSense Error

Here is my folder structure:

XAMPP/
├─ htdocs/
│  ├─ encryption_project/
│  │  ├─ index.php
│  │  ├─ composer.lock
│  │  ├─ composer.json
│  │  ├─ vendor/
│  │  │  ├─ autoload.php
│  │  │  ├─ web-token/
│  │  │  │  ├─ jwt-encryption/
│  │  │  │  ├─ jwt-core/

I'm using XAMPP (Apache Web Server) to run my PHP code and editing in VSCode.

My OS is MacOS Monterey. My PHP version is 8.1.6

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文