Skip to content

Commit e634168

Browse files
committed
first commit
0 parents  commit e634168

File tree

8 files changed

+266
-0
lines changed

8 files changed

+266
-0
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
phpunit.phar
3+
/vendor
4+
composer.phar
5+
composer.lock
6+
*.project
7+
.idea/

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Jens Segers
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
Outputs information about PHP's configuration
2+
======
3+
4+
`phpinfo()`函数的laravel-admin版本, Inspired by [nova-phpinfo](https://github.com/davidpiesse/nova-phpinfo)
5+
6+
## 截图
7+
8+
![wx20180906-141140](https://user-images.githubusercontent.com/1479100/45138456-113f8900-b1df-11e8-98f0-399cb1e2e1b2.png)
9+
10+
## 安装
11+
12+
```bash
13+
composer require laravel-admin-ext/phpinfo
14+
```
15+
16+
如果要在左侧菜单添加一个链接入口,用下面的命令导入
17+
```bash
18+
php artisan admin:import phpinfo
19+
```
20+
21+
## 配置
22+
23+
`config/admin.php`文件的`extensions`,加上属于这个扩展的配置
24+
```php
25+
26+
'extensions' => [
27+
28+
'phpinfo' => [
29+
30+
// 如果要关掉这个扩展,设置为false
31+
'enable' => true,
32+
33+
// 设置要显示的内容,参考 http://php.net/manual/en/function.phpinfo.php#refsect1-function.phpinfo-parameters
34+
'what' => INFO_ALL,
35+
36+
// 设置访问路径,默认为phpinfo
37+
//'path' => '~phpinfo',
38+
]
39+
]
40+
41+
```
42+
43+
## 使用
44+
45+
安装完成之后打开`http://localhost/admin/phpinfo`
46+
47+
## 支持
48+
49+
如果觉得这个项目帮你节约了时间,不妨支持一下;)
50+
51+
![-1](https://cloud.githubusercontent.com/assets/1479100/23287423/45c68202-fa78-11e6-8125-3e365101a313.jpg)
52+
53+
License
54+
------------
55+
Licensed under [The MIT License (MIT)](LICENSE).

composer.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "laravel-admin-ext/phpinfo",
3+
"description": "Show php information in laravel-admin",
4+
"type": "library",
5+
"keywords": ["laravel-admin", "extension", "phpinfo"],
6+
"homepage": "https://github.com/laravel-admin-ext/phpinfo",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "song",
11+
"email": "zosong@126.com"
12+
}
13+
],
14+
"require": {
15+
"php": ">=7.0.0",
16+
"encore/laravel-admin": ">=1.5.20"
17+
},
18+
"require-dev": {
19+
"phpunit/phpunit": "~6.0"
20+
},
21+
"autoload": {
22+
"psr-4": {
23+
"Encore\\PHPInfo\\": "src/"
24+
}
25+
},
26+
"extra": {
27+
"laravel": {
28+
"providers": [
29+
"Encore\\PHPInfo\\PHPInfoServiceProvider"
30+
]
31+
32+
}
33+
}
34+
}

resources/views/phpinfo.blade.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<div class="row">
2+
3+
<div class="col-md-offset-2 col-md-8">
4+
@foreach($info as $name => $section)
5+
6+
<div class="box">
7+
<div class="box-header">
8+
<h3 class="box-title">{!! $name !!}</h3>
9+
</div>
10+
<!-- /.box-header -->
11+
<div class="box-body no-padding">
12+
<table class="table table-striped">
13+
<tbody>
14+
15+
@foreach ($section as $key => $val)
16+
@if (is_a($val, 'Illuminate\Support\Collection'))
17+
<tr>
18+
<td>{!! $key !!}</td>
19+
<td class="phpinfo-v">{!! $val[0] !!}</td>
20+
<td>{!! $val[1] !!}</td>
21+
</tr>
22+
@elseif(is_array($val))
23+
<tr>
24+
<td>{!! $key !!}</td>
25+
<td class="phpinfo-v">{!! $val[0] !!}</td>
26+
<td>{!! $val[1] !!}</td>
27+
</tr>
28+
@elseif(is_string($key))
29+
<tr>
30+
<td>{!! $key !!}</td>
31+
<td class="phpinfo-v">{!! $val !!}</td>
32+
<td></td>
33+
</tr>
34+
@else
35+
<tr>
36+
<td>{!! $val !!}</td>
37+
<td></td>
38+
<td></td>
39+
</tr>
40+
@endif
41+
@endforeach
42+
</tbody>
43+
</table>
44+
</div>
45+
<!-- /.box-body -->
46+
</div>
47+
@endforeach
48+
</div>
49+
50+
</div>
51+
52+
<style>
53+
.phpinfo-v {
54+
overflow-x: auto;
55+
word-wrap: break-word;
56+
word-break: break-all;
57+
}
58+
</style>

routes/web.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
use Encore\Admin\Layout\Content;
4+
use Encore\PHPInfo\PHPInfo;
5+
6+
$path = PHPInfo::config('path', 'phpinfo');
7+
8+
Route::get($path, function (Content $content, PHPInfo $info) {
9+
$info = $info->toCollection();
10+
11+
return $content
12+
->header('PHP\'s configuration')
13+
->description(' ')
14+
->body(view('laravel-admin-phpinfo::phpinfo', compact('info')));
15+
});

src/PHPInfo.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace Encore\PHPInfo;
4+
5+
use Encore\Admin\Extension;
6+
7+
class PHPInfo extends Extension
8+
{
9+
public $name = 'phpinfo';
10+
11+
public $views = __DIR__ . '/../resources/views';
12+
13+
public $menu = [
14+
'title' => 'PHP info',
15+
'path' => 'phpinfo',
16+
'icon' => 'fa-exclamation',
17+
];
18+
19+
public function toCollection()
20+
{
21+
$what = static::config('what', INFO_ALL);
22+
23+
ob_start();
24+
25+
phpinfo($what);
26+
27+
$phpinfo = ['phpinfo' => collect()];
28+
29+
if (preg_match_all('#(?:<h2>(?:<a name=".*?">)?(.*?)(?:</a>)?</h2>)|(?:<tr(?: class=".*?")?><t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>)?)?</tr>)#s', ob_get_clean(), $matches, PREG_SET_ORDER)) {
30+
31+
collect($matches)->each(function ($match) use (&$phpinfo) {
32+
if (strlen($match[1])) {
33+
$phpinfo[$match[1]] = collect();
34+
35+
} elseif (isset($match[3])) {
36+
$keys = array_keys($phpinfo);
37+
38+
$phpinfo[end($keys)][$match[2]] = isset($match[4]) ? collect([$match[3], $match[4]]) : $match[3];
39+
} else {
40+
$keys = array_keys($phpinfo);
41+
42+
$phpinfo[end($keys)][] = $match[2];
43+
}
44+
});
45+
}
46+
47+
ob_end_clean();
48+
49+
return collect($phpinfo);
50+
}
51+
}

src/PHPInfoServiceProvider.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Encore\PHPInfo;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
7+
class PHPInfoServiceProvider extends ServiceProvider
8+
{
9+
/**
10+
* {@inheritdoc}
11+
*/
12+
public function boot(PHPInfo $extension)
13+
{
14+
if (! PHPInfo::boot()) {
15+
return ;
16+
}
17+
18+
if ($views = $extension->views()) {
19+
$this->loadViewsFrom($views, 'laravel-admin-phpinfo');
20+
}
21+
22+
$this->app->booted(function () {
23+
PHPInfo::routes(__DIR__.'/../routes/web.php');
24+
});
25+
}
26+
}

0 commit comments

Comments
 (0)