我的应用程序在 Laravel 8 上使用laravel/passport 10.0.1. 将php开发服务器上的版本从升级7.4到 后8.0,It was not possible to parse your key, reason: ""出现错误(没有来自 openssl_error_string 的任何消息)。
任何想法如何解决它?
我正在尝试将我的 PHP 版本更新为全新的 PHP 8。我已按照本教程的类似步骤进行操作。但现在显示以下错误:
12:06:23 [Apache] Error: Apache shutdown unexpectedly.
12:06:23 [Apache] This may be due to a blocked port, missing dependencies,
12:06:23 [Apache] improper privileges, a crash, or a shutdown by another method.
12:06:23 [Apache] Press the Logs button to view error logs and check
12:06:23 [Apache] the Windows Event Viewer for more clues
12:06:23 [Apache] If you need more help, copy and post this
12:06:23 [Apache] entire log window on the forums
Run Code Online (Sandbox Code Playgroud)
注意:我使用了全新的 XAMPP …
下面的内容false在 PHP 7 上返回,但true在 PHP 8 上返回。有人可以解释为什么会发生这种情况吗?
var_dump("U0M262" > 100000);
Run Code Online (Sandbox Code Playgroud) 假设我有以下属性声明
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
class Route
{
public function __construct(
public string $path,
public ?string $method = null,
public ?string $alias = null
)
{}
}
Run Code Online (Sandbox Code Playgroud)
我在一些控制器方法中使用它,如下所示:
class Controller
{
#[Route('/index/')]
#[Route('/home/', alias: 'home')]
public function index()
{
...
}
#[Route('/create/', 'POST')]
public function create(Request $request)
{
//...
}
}
Run Code Online (Sandbox Code Playgroud)
我如何获取这些属性实例并读取它的属性?
我已经更改了 Symfony 项目的配置,以在实体中使用 PHP 属性和 Doctrine。我对此感到非常高兴并想尝试一下。
我已将我的doctrine.yaml从更改annotation为attribute
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
type: attribute
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
Run Code Online (Sandbox Code Playgroud)
并在我的实体中使用属性
#[ORM\Entity(UserRepository::class)]
class User implements UserInterface
{
#[ORM\Id()]
#[ORM\GeneratedValue()]
#[ORM\Column(type: "integer")]
private ?int $id;
#[ORM\Column(type: "string", length: 180, unique: true)]
private ?string $email;
#[ORM\Column(type: "json")]
private array $roles = [];
}
Run Code Online (Sandbox Code Playgroud)
有了这个配置,我的php bin/console do:sc:up -f工作就很好。
但是当我尝试生成一个新实体时,php bin/console make:entity出现以下错误:
[错误] make:entity 仅支持注释映射,但 App\Entity\Toto 类使用不同的格式。如果您希望此命令生成属性和 getter/setter 方法,请添加映射 …
我这样启动我的服务器:
php -c /usr/local/etc/php/8.0/php.ini -S 127.0.0.1:8080 index.php
注意:是的,我知道这个-q选项,但这也会使errog_log()和syslog()输出静音。我想看到这些,因为我在开发和调试时阅读了它们。请不要提供该解决方案,除非您还知道配置其他内容的方法,以便仍然显示error_log()和syslog()......或者如果只有一些完全不同的方法来访问该error_log()和syslog()输出。:)
当我浏览到应用程序的主页时,我被无用的输出淹没,这些输出完全隐藏了我添加来帮助我调试的错误日志。例如。我添加error_log(uniqid()." testing")到我的页面并重新加载浏览器,并受到以下输出的攻击:
$ php -c /usr/local/etc/php/8.0/php.ini -S 127.0.0.1:8080 index.php
[Thu Oct 28 21:18:39 2021] PHP 8.0.12 Development Server (http://127.0.0.1:8080) started
[Thu Oct 28 21:18:44 2021] 127.0.0.1:65498 Accepted
[Thu Oct 28 21:18:44 2021] 127.0.0.1:65499 Accepted
[Thu Oct 28 21:18:44 2021] 617b76249f935 testing <--- NOTE: the only line I actually wanted
[Thu Oct 28 21:18:44 2021] …Run Code Online (Sandbox Code Playgroud) 这是我的泊坞窗文件:
FROM php:8.0-fpm-buster
# Arguments defined in docker-compose.yml
ARG user
ARG uid
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
git \
curl \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
jpegoptim optipng pngquant gifsicle \
libonig-dev \
libxml2-dev \
zip \
sudo \
unzip \
npm \
nodejs \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install PHP …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 vultr 的 Ubuntu 22.04 服务器上安装 LEMP。\n我可以安装 Nginx sudo apt install -y nginx- 没问题。
但是当我尝试通过运行这些命令安装 php8.0 时
\nsudo apt install software-properties-common\nsudo add-apt-repository ppa:ondrej/php\nsudo apt-get update\nRun Code Online (Sandbox Code Playgroud)\n我不断收到错误The repository 'https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy Release' does not have a Release file.
sudo add-apt-repository ppa:ondrej/php这是运行命令后得到的结果
root@ubuntu:~# sudo add-apt-repository ppa:ondrej/php\nPPA publishes dbgsym, you may need to include 'main/debug' component\nRepository: 'deb https://ppa.launchpadcontent.net/ondrej/php/ubuntu/ jammy main'\nDescription:\nCo-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of …Run Code Online (Sandbox Code Playgroud) 我有一个 WordPress 插件,我们正在将托管从 PHP 7 升级到 8。我们有一个函数,可以从会话中的序列化日期字符串创建一个 DateTime 对象,并使用 DateTime 函数将其与现在进行比较diff。在 PHP 7 中这是有效的(例如给出 1 秒)。在 PHP 8 中,它给我们负一年加上 11 个月、29 天、23 小时、零(!)分钟和 1 秒!
我正在使用 PHP CLI 运行以下脚本。
<?php
$d = new DateTime();
echo '$d->format("r"): ' . $d->format('r') . "\n";
sleep(1);
$n = new DateTime( $d->format('r') );
$diff_d = $d->diff( new DateTime() );
$diff_n = $n->diff( new DateTime() );
echo "\n";
echo 'print_r($diff_d)' . "\n";
print_r($diff_d);
echo "\n";
echo 'print_r($diff_n)' . "\n";
print_r($diff_n);
echo "\n";
echo 'd' …Run Code Online (Sandbox Code Playgroud) 此代码在 PHP 8 中给出的结果与所有以前版本的 PHP 中的结果不同:
if ('' == 0)
echo 'PHP '.phpversion().' says yes';
else
echo 'PHP '.phpversion().' says no';
PHP 7.2.12 says yes
PHP 7.4.14 says yes
PHP 8.0.0 says no
Run Code Online (Sandbox Code Playgroud)
这似乎是一个重大变化。这里发生了什么?
php-8 ×10
php ×9
apache ×1
attributes ×1
datetime ×1
doctrine-orm ×1
gd ×1
laravel-8 ×1
libjpeg ×1
nginx ×1
php-8.1 ×1
symfony ×1
ubuntu ×1
ubuntu-20.04 ×1
xampp ×1