小编leo*_*sta的帖子

更改 InertiaJS-Laravel 默认的 RootView

我正在使用Laravel 8并且已经安装InertiaJS,但是在我的目录中resources/views/我有一个名为的文件index.blade.php,我计划与InertiaJS.

默认情况下,InertiaJS在该目录中查找名为app.blade.php. 我知道写以下语句:

\Inertia\Inertia::setRootView('index');

更改rootView并允许我使用我创建的文件。这似乎是一个愚蠢的问题,但据我所知,我可以做两件事..

  • 将文件重命名index.blade.phpapp.blade.php
  • 写上一句.. 在ServiceProviders我所拥有的其中一个中

我想知道以下几点:

  • InertiaJS-Laravel不允许ServiceProvider使用命令发布php artisan vendor:publish(此命令的输出没有显示关于此包的任何要发布的内容)
  • 为了解决我的问题,我应该创建一个ServiceProviderlike:php artisan make:provider InertiaServiceProvider然后注册它?
  • 或者只是将前一个语句添加到ServiceProvider已经存在的语句之一?像app/Http/Providers/RouteServiceProvider.php

你有什么建议会更好?

我想在我的项目中寻找最大的组织。非常感谢您提前...

inertiajs laravel

5
推荐指数
4
解决办法
2441
查看次数

Symfony Finder:获取具有特定扩展名的所有文件以及特定目录中的所有目录

我正在使用 来Symfony Finder获取具有特定扩展名的所有文件以及特定目录中的所有目录。

\n
\n    protected function getDirectoryContent(string $directory): array\n    {\n        $finder = Finder::create()\n            ->in($directory)\n            ->depth(0)\n            ->name(['*.json', '*.php'])\n            ->sortByName();\n\n        return iterator_to_array($finder, true);\n    }\n\n
Run Code Online (Sandbox Code Playgroud)\n

这样,该方法只返回所有具有扩展名.php.json在某个目录内的文件。例如,我正在查看的目录结构如下:

\n
/my/directory/\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 A\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 A.JSON\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 anotherfile.kas\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 file0.ds\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 file1.json\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 file2.php\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 file3.php\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 B\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 C\n
Run Code Online (Sandbox Code Playgroud)\n

ABC是目录。

\n

当我将上面的内容directory path作为$directory参数传递到上面所示的方法中时,我得到一个包含以下元素的数组:

\n
file1.json\nfile2.php\nfile3.php\n
Run Code Online (Sandbox Code Playgroud)\n

太棒了!但我的问题是,我怎样才能将所有这些添加directories到结果数组中?我的期望是得到一个如下所示的数组:

\n
A\nB\nC\nfile1.json\nfile2.php\nfile3.php\n
Run Code Online (Sandbox Code Playgroud)\n

php symfony symfony4

3
推荐指数
1
解决办法
6981
查看次数

标签 统计

inertiajs ×1

laravel ×1

php ×1

symfony ×1

symfony4 ×1