我设置了一个干净的 Laravel 9 项目。然后我使用 RoadRunner 设置 Octane。
我在 Windows 11 主机中的 VirtualBox VM 上运行它。
我的电脑:
CPU:锐龙5 3600
内存:32GB - 2x16GB DDR4 3200Mhz CL16
存储:三星 970 Evo(未加),500GB
虚拟机:
CPU:4核
内存:4GB
存储:固定10GB
我使用 nginx 测试并比较了 PHP-FPM 和 Octane 之间的性能wrk:https:
//github.com/wg/wrk
在 Laravel 的默认主页上运行基准测试
这些是每个设置的 nginx 配置文件:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
listen [::]:80;
server_name myapp.dev;
server_tokens off;
root /var/www/html/myapp/public;
index index.php;
charset utf-8;
location /index.php {
try_files /not_exists @octane;
}
location …Run Code Online (Sandbox Code Playgroud) 我目前使用的是 Windows 11,但我认为 Windows 10 的步骤相同。
我到处搜索,没有一个教程显示如何在 Windows 上成功安装 OpenSSL。
本网站上的所有答案都只是解决方法,例如使用 Git 版本。我专门使用 XAMPP 中的 OpenSSL,但这不是我想要的。
我希望能够从源代码安装 OpenSSL。另外,当前 Git 和 XAMPP 安装 OpenSSL 版本 1.1.1,我想要 OpenSSL 3。
我已经尝试了所有方法,但 OpenSSL 说明缺少信息。他们只是说一些提示,然后是三个点 (...),例如 ( ./Configure...)。
这就是我试图遵循的地方:
https://github.com/openssl/openssl/blob/master/NOTES-WINDOWS.md#native-builds-using-mingw
对于这个例子,我选择了 MinGW 方法(但是,如果您可以帮助通过其他方法之一成功安装它,那么也没关系,我也会这样做):
我在 Windows 上安装了 MSYS32 和 Perl,但后来我陷入了 MinGW 部分,我已经在 MSYS32 上安装了 MinGW - 我刚刚安装了工具链中的所有软件包:
$ pacman -S mingw-w64-ucrt-x86_64-toolchain
:: There are 19 members in group mingw-w64-ucrt-x86_64-toolchain:
:: Repository ucrt64
1) mingw-w64-ucrt-x86_64-binutils 2) mingw-w64-ucrt-x86_64-crt-git
3) mingw-w64-ucrt-x86_64-gcc 4) mingw-w64-ucrt-x86_64-gcc-ada
5) mingw-w64-ucrt-x86_64-gcc-fortran 6) mingw-w64-ucrt-x86_64-gcc-libgfortran
7) …Run Code Online (Sandbox Code Playgroud) 我刚刚使用 Jetstream 入门套件安装了一个干净的 Laravel 项目,因此它还安装了 Tailwind CSS。
然后我尝试使用 Tailwind 中的示例代码,但它不会显示。
这是我来自 Tailwind 文档的简单测试代码:(来自https://tailwindcss.com/docs/hover-focus-and-other-states)
app.blade.php:(您可以运行代码片段,因为这实际上是我在项目中得到的)
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Fonts -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap">
<!-- Styles -->
<link rel="stylesheet" href="{{ mix('css/app.css') }}">
<!-- Scripts -->
<script src="{{ mix('js/app.js') }}" defer></script>
</head>
<body class="font-sans antialiased">
<button class="bg-red-500 hover:bg-red-700">
Hover me
</button>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
这是tailwind.config.js文件:
const defaultTheme …Run Code Online (Sandbox Code Playgroud) 是否可以根据另一个输入的值有条件地验证输入字段?
例如,有一个type可以包含值的输入letters,或者numbers,然后有另一个包含该value输入的字段。
我希望value输入验证规则是alphaif type isletters和numericif type isnumbers
我已经在rules方法中使用管道类型的验证:
public function rules()
{
return [
"type" => 'required',
"value" => 'required|min:1|max:255',
];
}
Run Code Online (Sandbox Code Playgroud) 当我在 Android Studio 上创建一个空片段时,它会生成以下代码:
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link TestFragment.OnFragmentInteractionListener} interface
* to handle interaction events.
* Use the {@link TestFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class TestFragment extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = …Run Code Online (Sandbox Code Playgroud) 我已经从这篇文章中看到了解决方案:“/sf/ask/3538707931/
但这个解决方案还不够
问题是,如果我执行解决方案中所述的操作,即chown -R www-data:www-data *在 Docker 容器内运行 - 它还会更改 Ubuntu 主机中实际文件夹的权限,而不仅仅是容器,因为我在文件中设置了此文件夹docker-compose.yml:
php:
build:
context: ./laravel
dockerfile: Dockerfile
container_name: laravel
volumes:
- ./laravel:/var/www/html
Run Code Online (Sandbox Code Playgroud)
这是Dockerfile:
FROM php:fpm-alpine
RUN docker-php-ext-install pdo pdo_mysql
Run Code Online (Sandbox Code Playgroud)
我在Ubuntu主机中的用户是myuser这样,当我运行时chown -R www-data:www-data *, myuser不再具有主机上的权限,并且我无法保存文件。
因此,我要么在localhostURL 上获得权限被拒绝(如另一篇文章中所示),要么在我的 Ubuntu 主机上的 VS Code 上保存文件的权限被拒绝!(我正在使用 WSL2,这就是为什么我可以使用 VS Code)
把它们加起来:
myuser我必须运行sudo chown -R myuser ~/myprojectwww-data,因此我无法访问我的网站localhost- 如上面的帖子所示。我需要在循环中创建一些 BitSet,例如:
ArrayList<BitSet> bitSetList = new ArrayList<BitSet>();
for (int x : array) {
bitsetList.add(new BitSet() //and set bits in specific places)
}
Run Code Online (Sandbox Code Playgroud) 我遵循以下指南:
https://getbootstrap.com/docs/5.2/getting-started/vite/
我仍然遇到各种错误,有时找不到文件,有时我只是看不到引导程序设计。
我使用 npm 安装了 Bootstrap:
npm install bootstrap@5.2.2
Run Code Online (Sandbox Code Playgroud)
然后我使用 npm 安装了 scss:
npm i --save-dev sass
Run Code Online (Sandbox Code Playgroud)
然后我将以下内容添加到vite.config.js:
resolve: {
alias: {
'~bootstrap': path.resolve(__dirname, 'nodes_modules/bootstrap'),
}
}
Run Code Online (Sandbox Code Playgroud)
还添加了以下内容/resources/app.js:
import '/resources/scss/styles.scss'
import * as bootstrap from 'bootstrap';
Run Code Online (Sandbox Code Playgroud)
我还创建了一个新scss文件夹/resources,并将以下styles.scss文件放入其中:
// Import all of Bootstrap's CSS
@import "~bootstrap/scss/bootstrap";
Run Code Online (Sandbox Code Playgroud)
但是当我使用npm run devor时build,Bootstrap 样式不会显示,或者我收到有关文件不存在的错误,例如:
[plugin:vite:css] [sass] ENOENT: no such file or directory, open '/var/www/myapp/nodes_modules/bootstrap/scss/bootstrap
Run Code Online (Sandbox Code Playgroud) 使用 Alpine.js + TailwindCSS。
每当页面重新加载时,侧边栏就会显示一瞬间然后关闭。我不明白为什么会发生这种情况。
我什至尝试将block类添加到<aside>元素中,然后在侧边栏打开时显示它,如下所示::class="open ? 'translate-x-0 block' : '-translate-x-full'"但这也不起作用
它看起来是这样的:
<script defer src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet"/>
<nav x-data="{ open: false, toggle() { this.open = ! this.open } }" class="flex w-full items-center justify-between px-6 h-16 bg-white text-gray-700 border-b border-gray-200 z-10">
<div class="flex flex-row-reverse items-center">
<button @click="toggle(open)" class="mr-2" aria-label="Open Menu">
<svg fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24" class="w-8 h-8">
<path d="M4 6h16M4 12h16M4 18h16"></path>
</svg>
</button>
</div>
<transition enter-class="opacity-0" enter-active-class="ease-out transition-medium" …Run Code Online (Sandbox Code Playgroud)我将键值对添加到我的数组中,如下所示:
$array[] =
[
"key1" => "value1",
"key2" => "value2",
// ...
]
Run Code Online (Sandbox Code Playgroud)
我想添加另一个 key ,前提是设置了foo变量:$bar
$array[] =
[
"key1" => "value1",
"key2" => "value2",
"foo" => $bar
// ...
]
Run Code Online (Sandbox Code Playgroud)
"foo" => $foo仅当$foo设置时如何添加对?
我现在做的是如果未设置则""向键添加空 ( ) 值,但我根本不想添加它"foo"$bar
我有一个对象,其中包含数组形式的对象的键对值:
let obj = {};
let joinedData;
obj["key1"] = ["val1", "val2"];
obj["key2"] = ["val3", "val4"];
Run Code Online (Sandbox Code Playgroud)
我想将所有值连接在一起作为一个字符串:
for (const [key, values] of Object.entries(obj)) {
joinedData = `${values.join(",")}`;
}
Run Code Online (Sandbox Code Playgroud)
预期结果是"val1,val2,val3,val4"
却joinedData是空空如也。
我怀疑这是因为它们values是对象而不是数组(当我使用时typeof)。
这种情况下如何得到预期的结果呢?